r-spatial / rgee

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

Error with using reduceRegion with a grouped Reducer #223

Closed gltyree closed 2 years ago

gltyree commented 2 years ago

At submit an issue, please attached the following information of your rgee session:

library(rgee)

# Initialize the Earth Engine module.
ee_Initialize()

# Print metadata for a DEM dataset.
print(ee$Image('USGS/SRTMGL1_003')$getInfo())

Attach your Python (reticulate) configuration:

library(reticulate)
py_config()

Description

Hi rgee team,

I want to get mean values for an image by using a grouped Reducer:

What I Did

Paste the command(s) you ran and the output.
If there was a crash, please include the traceback here.
csaybar commented 2 years ago

Hi @gltyree, something like this should work

library(rgee)

ee_Initialize()

srtm_model <- ee$Image$Dataset$CGIAR_SRTM90_V4
ee_geom <- ee$Geometry$Point(c(8.76361, 50.81838)) %>% 
  ee$Geometry$buffer(100)
ee_extract(srtm_model, ee_geom, ee$Reducer$mean())