3

How can I extarct mean of each image collection in google earth engine? for example for this code:

var modis = ee.ImageCollection("MODIS/006/MOD13Q1")
.filterBounds(geometry)
.filterDate("2000-01-01","2001-01-01")
.select("NDVI");

print(modis)

var mod13 = modis.map(function(img){
  return img.multiply(0.0001)
  .copyProperties(img,['system:time_start','system:time_end']);
});
2
  • Do you want the pixel-wise mean for each pixel or the mean per image/scene?
    – Kersten
    Nov 3, 2018 at 12:45
  • I'm going to extract mean of each image which is called with image collection(mean per image). Nov 3, 2018 at 15:07

1 Answer 1

3

Earth Engine provides very nice functionality to calculate statistics on imagery called reducers. There are plenty of ways to use reducers but as simple examples you can calculate the statistics at the pixel level or provide a geometry to calculate statistics:

var modis = ee.ImageCollection("MODIS/006/MOD13Q1")
.filterDate("2000-01-01","2001-01-01")
.select("NDVI");

print(modis)

var mod13 = modis.map(function(img){
  return img.multiply(0.0001)
  .copyProperties(img,['system:time_start','system:time_end']);
});

// calculate the mean of value for each pixel
var meanMod13 = mod13.reduce(ee.Reducer.mean())
Map.addLayer(meanMod13,{min:0,max:1},'Mean NDVI')

// calculate the mean value for a region
var geom = ee.Geometry.Rectangle([-88,34,-87,35])
Map.addLayer(geom)
// *Note that reduceRegion works only on ee.Image not ee.ImageCollection data types
var zonalStats = meanMod13.reduceRegion({
    geometry: geom,
    reducer: ee.Reducer.mean(),
    scale: 1000,
    bestEffort: true
});
print(zonalStats)

I hope this helps!

2
  • How could I use the mean per region for all images of an ImageCollection? So it automatically does it and gives me the results in a list. With a function?
    – xdsccc
    Mar 28, 2021 at 9:04
  • Yes, you can create a function that takes an image as input, applies the reduction and outputs the statistics as a feature so the output will be a feature collection. The function will need to be mapped over the image collection and you can get the list of values out of the feature collection. Mar 29, 2021 at 19:41

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.