0

This question already has an answer here:

I have a polygon and I want to calculate its mean NDVI values from 2000-2003 (and few more periods) but only for March so the final result should be image which contains the mean NDVI values only for march between 2000-2003.

How can I do that?

This is the code I have written until now:

var dataset = ee.ImageCollection('MODIS/006/MOD13A1')
                  .filter(ee.Filter.date('2000-03-01', '2000-03-31'))
                  .select('NDVI')
                  .mean()
                  .clip(geometry)
                  ;
//var ndvi = dataset.select('NDVI')
var ndviParams = {min: -2000, max: 10000, palette: [
    'FFFFFF', 'CE7E45', 'DF923D', 'F1B555', 'FCD163', '99B718', '74A901',
    '66A000', '529400', '3E8601', '207401', '056201', '004C00', '023B01',
    '012E01', '011D01', '011301'
  ]};

 Map.centerObject(geometry, 7)
Map.addLayer(dataset,ndviParams,'NDVI2') 

marked as duplicate by aldo_tapia, whyzar, Jochen Schwarze, Vince, LaughU Apr 26 at 9:34

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

3

You should use the ee.Filter() calendarRange(start, end, field) after you filtered the image collection between the years you are interested in.

var dataset = ee.ImageCollection('MODIS/006/MOD13A1')
                  .filter(ee.Filter.date('2000-01-01', '2004-01-01'))
                  .select('NDVI');

// filter the image collection to contain only images from March
var onlyMarch = dataset.filter(ee.Filter.calendarRange(3, 3,'month')); print(onlyMarch)
// make a composite (mean image) of the images of March and clip to the geometry
var meanImage = onlyMarch.mean().clip(geometry); print(meanImage)

//var ndvi = dataset.select('NDVI')
var ndviParams = {min: -2000, max: 10000, palette: [
    'FFFFFF', 'CE7E45', 'DF923D', 'F1B555', 'FCD163', '99B718', '74A901',
    '66A000', '529400', '3E8601', '207401', '056201', '004C00', '023B01',
    '012E01', '011D01', '011301'
  ]};

Map.centerObject(geometry, 7)
Map.addLayer(meanImage,ndviParams,'NDVI2') 

link code

  • thanks! it worked:) – Reut Apr 25 at 15:46

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