# NOT RUN {
library(rgee)
library(stars)
library(sf)
username <- 'data.colec.fbf' #change according to username.
gcs_bucket <- 'rgee_dev'
ee_check_drivers()
ee_reattach() # reattach ee as a reserved word
ee_Initialize(email = 'data.colec.fbf', gcs = TRUE)
# Create a folder in Earth Engine Asset
filename <- sprintf("users/%s/rgee_upload/", username)
ee_manage_create(filename)
# Select an image to upload
tif = system.file("tif/geomatrix.tif", package = "stars")
geomatrix = read_stars(tif) %>% st_warp(crs=st_crs(4326))
# Uploading to earth egnine
ee_upload(x = geomatrix,
filename = paste0(filename,"geomatrix"),
bucket = gcs_bucket)
# Read uploaded image
asset_geomatrix <- paste0(filename,"geomatrix")
ee_geomatrix <- ee$Image(asset_geomatrix)
ee_map(ee_geomatrix, zoom_start = 18)
## OPTIONAL: add properties
ee_manage_set_properties(
path_asset = asset_geomatrix,
add_properties = list(message='hello-world',language = 'R'))
# Clean EE asset and GCS
ee_manage_delete(dirname(asset_geomatrix))
googleCloudStorageR::gcs_global_bucket(gcs_bucket)
buckets <- googleCloudStorageR::gcs_list_objects()
mapply(googleCloudStorageR::gcs_delete_object, buckets$name)
# }
Run the code above in your browser using DataLab