Learn R Programming

rgee (version 0.5.0)

gcs_to_ee_table: Move a zipped shapefile from GCS to their EE Assets

Description

Move a zipped shapefile from GCS to their EE Assets

Usage

gcs_to_ee_table(gs_uri, assetId, overwrite = FALSE, quiet = FALSE)

Arguments

gs_uri

Character. It represents the full name of an zipped shapefile in a GCS bucket.

assetId

Character. What to call the file once uploaded to their Earth Engine Assets

overwrite

Logical. If TRUE, the assetId will be overwritten if it exists.

quiet

Logical. Suppress info message.

Examples

Run this code
# NOT RUN {
library(rgee)
library(sf)
ee_Initialize(gcs = TRUE)

# Create sf object
nc <- st_read(system.file("shape/nc.shp", package="sf"))
assetId <- sprintf("%s/%s",ee_get_assethome(),'sf_nc')

# Method 1
# 1. Pass the sf to a zip file
zipfile <- ee_utils_shp_to_zip(nc)

# 2. From local to gcs
gs_uri <- local_to_gcs(x = zipfile, bucket = 'rgee_dev')

# 3. Pass the sf to a zip file
gcs_to_ee_table(
  gs_uri = gs_uri,
  assetId = assetId
)

# OPTIONAL: Monitoring progress
ee_monitoring()

# OPTIONAL: Display results
ee_sf_01 <- ee$FeatureCollection(assetId)
Map$centerObject(ee_sf_01)
Map$addLayer(ee_sf_01)

# Method 2
ee_sf_02 <- sf_as_ee(x = nc,
                     assetId = assetId,
                     bucket = "rgee_dev",
                     via = 'gcs')
Map$centerObject(ee_sf_02)
Map$addLayer(ee_sf_02)
# }

Run the code above in your browser using DataLab