r-spatial / rgee

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

Total request size larger than allowed while converting from GEE object to R object #326

Open Ekena opened 1 year ago

Ekena commented 1 year ago

When submitting an issue, please attach the following information about your rgee session:

python: C:/Users/ekena/AppData/Local/r-miniconda/envs/rgee/python.exe libpython: C:/Users/ekena/AppData/Local/r-miniconda/envs/rgee/python38.dll pythonhome: C:/Users/ekena/AppData/Local/r-miniconda/envs/rgee version: 3.8.16 | packaged by conda-forge | (default, Feb 1 2023, 15:53:35) [MSC v.1929 64 bit (AMD64)] Architecture: 64bit numpy: C:/Users/ekena/AppData/Local/r-miniconda/envs/rgee/Lib/site-packages/numpy numpy_version: 1.24.2 ee: C:\Users\ekena\AppData\Local\R-MINI~1\envs\rgee\lib\site-packages\ee__init__.p

NOTE: Python version was forced by RETICULATE_PYTHON

Description

Hello everyone,

I've been trying to read a dataset stored as an asset in my Earth Engine account. It is a stack of rasters that I would like to use as predictors of a model trained in R. However, when I load the tiled images from GEE, make a composite, and try to convert them to an R object, a get an error related to the total request size.

I wonder if there is a way around this problem. I thought that maybe requesting the tiles first and then compositing, but I have no idea how to implement this.

What I Did

library(rgee) library(reticulate) ########## Initialize Earth Engine and Google Drive Sys.setenv(PATH = sprintf("%s:%s", Sys.getenv("PATH"), sprintf("%s/google-cloud-sdk/bin/", Sys.getenv("HOME")))) ee_check() ee_Initialize() ########## Read the study area polygon roi <- ee$FeatureCollection('users/ekenarp/Amazon_Biome_MT') ########## Import and mosaic GEE assets assetCollection <- 'users/ekenarp/Sentinel_GLCM_Amazon_MT' composite <- ee$ImageCollection(assetCollection)$mosaic() ########## Convert the GEE object to an R RasterLayer object roi_geom <- roi$geometry() GLCM_Amazon_MT <- ee_as_rast( image = composite, region = roi_geom, scale = 500 )

Error with Traceback

Error in py_call_impl(callable, dots$args, dots$keywords) : ee.ee_exception.EEException: Total request size (169921260 bytes) must be less than or equal to 50331648 bytes.

  1. stop(structure(list(message = "ee.ee_exception.EEException: Total request size (169921260 bytes) must be less than or equal to 50331648 bytes.\n", call = py_call_impl(callable, dots$args, dots$keywords), cppstack = NULL), class = c("Rcpp::exception", "C++Error", "error", "condition"))) 5.ee$Image$getDownloadURL(., list(scale = scale, format = "GEO_TIFF", region = geom_ee, filePerBand = FALSE)) 4.image %>% ee$Image$getDownloadURL(list(scale = scale, format = "GEO_TIFF", region = geom_ee, filePerBand = FALSE)) 3.ee_image_local_getDownloadURL_nocheck(image = image, geom_ee = sf_as_ee(geom_sf_batch[index], proj = crs_fullimg_epsg_str), scale = scale, dsn = tmpfiles[index], grid_batch = grid_batch, export = "file", format = format) 2.ee_image_local_getDownloadURL(image = image, dsn = dsn, quiet = quiet, scale = scale, grid_batch = grid_batch, export = "terra", format = "GEO_TIFF", geometry = region) 1.ee_as_rast(image = composite, region = roi_geom, scale = 500)