0

Is it possible to get statistics for multiple images at once using reduceRegions() function?

My case: I need to get statistics from multiple images (elev, slope, tree cover loss) for multiple region (grid)

// Add reducer output to the Features in the collection.
var gridmeans = elev.reduceRegions({
  collection: grid,
  reducer: ee.Reducer.mean(),
  scale: 30,
});

print(gridmeans);

Export.table.toDrive({
  collection: gridmeans,
  description:'biggridmeans',
  fileFormat: 'csv'
});
3

To get statistics for multiple locations from multiple images, you can combine images together using ee.Image.addBands() as shown in the following example:

// Define images.
var elev = ee.Image("NOAA/NGDC/ETOPO1");
print('elev', elev);

var slope = ee.Terrain.slope(elev.select('bedrock')).rename('bedrock_slope');
print('slope', slope);

// Stack the bands of multiple images together.
var stacked_image = elev.addBands(slope);
print('stacked_image', stacked_image);

// Define a feature collection (grid features).
var grid_1 = ee.Geometry.Rectangle(-105.29, 39.98, -105.28, 39.99);
var grid_2 = ee.Geometry.Rectangle(-105.28, 39.98, -105.27, 39.99);
var grid_3 = ee.Geometry.Rectangle(-105.27, 39.98, -105.26, 39.99);
var grid = ee.FeatureCollection([
  ee.Feature(grid_1, {'name': 'Grid 1'}),
  ee.Feature(grid_2, {'name': 'Grid 2'}),
  ee.Feature(grid_3, {'name': 'Grid 3'})
]);
Map.addLayer(grid, {}, 'grid');

// Add reducer output to the Features in the collection.
var gridmeans = stacked_image.reduceRegions({
  collection: grid,
  reducer: ee.Reducer.mean(),
  scale: 1000,
});
print('gridmeans', gridmeans);

Export.table.toDrive({
  collection: gridmeans,
  description:'biggridmeans',
  fileFormat: 'csv'
});

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.