TransWikia.com

Calculating Annual Mean NDVI for set of features using Google Earth Engine

Geographic Information Systems Asked by user175994 on April 29, 2021

I’m trying to calculate the annual mean NDVI for a set of polygons that are stored in a table in GEE. I want the annual mean for a series of years to be added to the table as new fields. I have the code to use the MODIS dataset to extract by day but I can’t figure out how to get the annual mean. Essentially, this output works, I just need to the annual mean instead of daily value.

var modisNDVI = ee.ImageCollection("MODIS/MCD43A4_006_NDVI").filterDate('2015-01-01', '2015-01-09');

// create dummy image.
 var stacked_image = ee.Image();

// create function to combine all images into one image as bands.
 var combine = function(img, stack){
  stack = ee.Image(stack);
  return stack.addBands(img.select([0], [img.get('system:index')]));
};

var rename_band = function(img){
  return img.select([0], [img.id()]);
};

// stack all the images into a single image.
stacked_image = modisNDVI.map(rename_band).toBands(); //iterate(combine, stacked_image);

// determine scale to perform reduceRegions.
var scale = modisNDVI.first().projection().nominalScale();
    var ndviMean = ee.ImageCollection(years).map(function(img){
      var rR = img.reduceRegions({collection: regions,
                                reducer: ee.Reducer.mean(),
                                scale: 500,
                                tileScale: 4})
      return rR.map(function(feat){
        return feat.set('year', img.get('year'))
      })
}).flatten()

Export.table.toDrive(ndviMean,"NDVI","NDVI","NDVI_zones");

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP