I have run into a very similar problem a few times while working in Google Earth Engine and never found a good solution.

I am working with raster data (continuous values) and a feature collection of ecosystems, and my goal is to summarize the raster values over a column within the feature collection. The ecosystems shapefile has a column that assigns each ecosystem to a biome (so there are 827 ecosystems and 14 biomes). I want to calculate the mean raster value over these biomes.

In ArcMap I would use zonal statistics as table and specify that I want to calculate the statistics over the biome column, but I have not found a good way to accomplish this in GEE. So far I have been using the reduceRegions function and specifying my feature collection as the collection, but this only lets me summarize the raster values over the 827 ecosystems.

Is there a function that would allow me to do this in GEE? Or would it be easier to just make the changes to the shapefile in Arc and then re-import it?

1 Answer 1


There are several options, but the most efficient will be to use a grouped reducer (there are detailed examples in the User's Guide at https://developers.google.com/earth-engine/guides/reducers_grouping).

It would look something like this:

// Create a raster of biomes
var biomes = ee.Image().int().paint(ecosystems, "biome").rename("biomes")

// Aggregate pixels, grouping on the biome band (the first one).
var results = biomes.addBands(raster)
    .reduceRegion(ee.Reducer.mean().group(0), roi, scale)

If you don't already have a fixed roi, you can probably just take the bounds of the ecosystems:

var aoi = ecosystems.geometry().bounds()
  • That worked great! I didn't think to convert to raster first
    – Sabine
    Feb 13, 2021 at 21:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.