Created
August 19, 2020 01:26
-
-
Save csaybar/54966df215720d0cc3c4078bce59a836 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(stars) | |
library(rgee) | |
# remotes::install_github("r-spatial/rgee@v.1.0.5") | |
ee_Initialize("csaybar", gcs = TRUE) | |
# Properties to attach to the uploaded raster | |
raster_properties <- list(prop2=1, prop1=2) | |
# ------------------------------------------------------------- | |
# Case N°01: Upload a raster to Earth Engine and set properties | |
# -------------------------------------------------------------- | |
# 1.1 Read the raster you want to upload | |
tif <- system.file("tif/L7_ETMs.tif", package = "stars") %>% | |
read_stars(proxy = TRUE) | |
# 1.2 Create a destination asset ID | |
asset_id <- sprintf("%s/%s", ee_get_assethome(),"l7_example") | |
# 1.3 Upload raster with stars_as_ee (or raster_as_ee) | |
ee_tif <- stars_as_ee( | |
x = tif, | |
assetId = asset_id, | |
overwrite = TRUE, | |
bucket = "rgee_dev", # set here your GCS bucket | |
properties = raster_properties # set here your properties (ee_utils_create_manifest_image) | |
) | |
ee_tif$get("prop1")$getInfo() | |
# ------------------------------------------------------------- | |
# Case N°02: Set properties to a previous raster uploaded | |
# -------------------------------------------------------------- | |
# 2.1 Specify a in/out EE path | |
server_path <- "LANDSAT/LC08/C01/T1/" | |
user_asset_path <- ee_get_assethome() | |
final_path <- paste0(user_asset_path,"/LC08_044034_20140318") | |
# 2.2 Copy an asset | |
ee_manage_copy( | |
path_asset = paste0(server_path,"/LC08_044034_20140318"), # server path | |
final_path = final_path # ur personal path | |
) | |
# 2.3 Set properties | |
ee_manage_set_properties(final_path, list(p1 = "rgee", p2 = 10)) | |
ee$Image(lc08)$get("p1")$getInfo() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment