r-spatial / rgee

Google Earth Engine for R
https://r-spatial.github.io/rgee/
Other
677 stars 146 forks source link

Can't download images from GCS bucket using `ee_gcs_to_local()` #249

Closed egbendito closed 2 years ago

egbendito commented 2 years ago

Python (reticulate) configuration:

python:         .virtualenvs/rgee/bin/python
libpython:      r-miniconda/envs/r-reticulate/lib/libpython3.6m.so
pythonhome:     .virtualenvs/rgee:.virtualenvs/rgee
version:        3.6.15 | packaged by conda-forge | (default, Dec  3 2021, 18:49:41)  [GCC 9.4.0]
numpy:          .virtualenvs/rgee/lib/python3.6/site-packages/numpy
numpy_version:  1.19.5
ee:             .virtualenvs/rgee/lib/python3.6/site-packages/ee

NOTE: Python version was forced by RETICULATE_PYTHON

Description

I am trying to export an image to Google Cloud Storage and from the bucket to my local fs in 2 steps (ee_image_to_gcs() and ee_gcs_to_local()). The first step exporting to GCS works fine, but downloading from GCS fails. I have resorted to using the goolCloudStorageR package, but that is suboptimal and I prefer native rgee functions.

Digging a bit, the error seems to come from sort_drive_files() in L1155 and 1156

What I Did

    ee_Initialize(user = "user", gcs = T)
    # Create image
    img <- ee$ImageCollection("MODIS/006/MOD13A2")$
      filterDate('2020-01-01', '2021-01-01')$
      filterBounds(ee$Geometry$BBox(25,45,30,50))$
      select("EVI")$
      mean()$
      clip(ee$Geometry$BBox(25,45,30,50))
    task_img <- ee_image_to_gcs(img, bucket = "my_bucket",
       scale = 1000, fileFormat = "GEO_TIFF",
       region = ee$Geometry$BBox(25,45,30,50), fileNamePrefix = "EVI")
    task_img$start()
    ee_monitoring(task_img)
    r <- ee_gcs_to_local(task = task_img, dsn = paste(tmp, "EVI", sep = '/'))

Error message:

Error in order(drive_files[["name"]]) : argument 1 is not a vector

P.S.: In the googleCloudStoageR approach, I am noticing a HUGE delay between the exporting of the images ee_image_to_gcs() and them being available through googleCloudStoageR::gcs_get_object(). Using ee_gcs_to_local(task = task_img) is instantaneous!! 🎉...

csaybar commented 2 years ago

Hi, @egbendito sorry for the very late reply I can't reproduce this error, can you share with me your traceback.

# run the line below when the error appears
traceback()

We have a new vignette with information about how to sync GCE + GEE + rgee: https://cran.r-project.org/web/packages/rgee/vignettes/rgee05.html