I'm trying to calculate the mean of all pixels at the county level for an image in Google Earth Engine and am using the rgee package in R Studio.
I've tried following the example here: https://github.com/csaybar/rgee/blob/examples/image/image_stats_by_band.R
The code runs but results in a long print out in R of feature$geometry$coordinates, feature$properties, etc., and I just want the mean value of the band and would like to use the mean value in subsequent calculations. I think I want one of the value in one of the last lines that is printed: $features[[1]]$properties$data
#GY16 is an image covering a U.S. state with 1 band and I would like to calculate the mean of that image at the county level. shp1 is the county geometry.
geometry <- shp1
means <- GY16$reduceRegions(
collection = geometry,
reducer = ee$Reducer$mean()$forEachBand(GY16),
scale=10
)
print(means$getInfo())
Any advice is appreciated. Thank you!
This example was made in rgee early versions, now you can use ee_extract: