I would like to reduce an image where the inputs are two images and the output is a table. One image will have zones (integer values) and the other data to summarize. For each zone in an image, I would like to calculate the mean of values in the other image that overlap that zone. In ArcGIS one could use the tool Zonal Statistics as Table.


//1- zone image (DEM binned 100m intervals)
//2- data to summarize (mean minimum temperature)
//3- figure out how to summarize mean tmin per dem zone and export as a csv

//zones (dem binned x 100m)
var DEM_binned = image.divide(100).ceil().clip(geometry);
Map.addLayer(DEM_binned, {min:0, max:40, palette:['blue', 'purple', 'green', 'yellow', 'orange', 'red', 'white']}, 'dem');

//data to summarize (mean long-term annual tmin)
var tmin = imageCollection.select('tmin');
var tmin = tmin.mean().clip(geometry);
Map.addLayer(tmin, {min: -5, max: 20, palette:['white', 'blue', 'green', 'yellow', 'red']}, 'tmin')

//get mean tmin per zone as a table

GEE working example script: https://code.earthengine.google.com/0f50cbfbbb8ee8eabad07d9569b9a58a

1 Answer 1


You could try converting your DEM with .reduceToVectors() and using this with .reduceRegions() to get your mean values. This might be very slow though, because .reduceToVectors() can take a while on rasters with a higher resolution.

Instead something like this might be quicker:

var bins = ee.List.sequence({
  start: -1,
  end: 80,
  step: 1

var scale = tmin.projection().nominalScale()
var tmins = bins.map(function(bin){
  var masked = tmin.mask(DEM_binned.eq(ee.Number(bin).toInt()))
  return masked.reduceRegion({
    reducer: ee.Reducer.mean(),
    scale: scale


Here we define a range of dem values right at the start (-100 to 8,000 m) which should cover all the values we need and then map over this list. You can also use step to change the binning. The big advantage here is that we only use reduceRegion() on the masked tmin raster which has a pretty low resolution. That way the computation time is probably a lot lower than with other methods, however I haven't tested that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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