2

I'm trying to loop a ReduceRegion function in Google Earth Engine to obtain a month mean NDVI over a polygon. But I've not been successful yet. I did for one month. At the end, I should have a list or dictionary with 132 mean values of NDVI and date associate.

// Gerar tabela com os valores médios de NDVI mensal da série histórica ????????
// Compute mean NDVI for "limite" for all years. I got it for one month. But don't know to do it for all month in "byMonthYearDoce". 

var meanDictionary = ee.Image(byMonthYearDoce.first()).reduceRegion({
  reducer: ee.Reducer.mean(),
  geometry: limite,
  scale: 250,
  maxPixels: 1e9
});

print(meanDictionary)

https://code.earthengine.google.com/b934bf833d99ebf4f3e2298748c7ecd9

2

You will have to map over the image collection and apply reduceRegion on each image:

var imageCollection = byMonthYearDoce.map(function(image){
  var dictionary = image.reduceRegion({
    reducer: ee.Reducer.mean(),
    geometry: limite,
    scale: 250,
    maxPixels: 1e9
  });
  return ee.Image(image.setMulti(dictionary)); 
});

print('as List', ee.List(imageCollection.aggregate_array('NDVI')))

Optionally, you could write this to a dictionary with names i toke from your image properties (month and year):

// write to dictionary
var keys = ee.List.sequence(0, imageCollection.size().subtract(1)).map(function(i){
  var index = ee.String(ee.Number(i).toInt());
  var image = imageCollection.filter(ee.Filter.eq('id', index)).first();
  var year = ee.String(ee.Number(image.get('year')).toInt());
  var month = ee.String(ee.Number(image.get('month')).toInt());
  return ee.String('meanNDVI').cat('_').cat(year).cat('_').cat(month);
});

// construct dictionary
var meandictionary =  ee.Dictionary.fromLists(keys, ee.List(imageCollection.aggregate_array('NDVI')));
print('as ditionary', meandictionary)

link

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