Saturday 6 April 2019

landsat - Writing code for monthly NDVI medians in Google Earth Engine?



My goal is to get monthly NDVI medians in Google Earth Engine. This helpful post got me started: reduce image collection to get annual monthly sum precipitation


However, I am using Landsat (not MODIS). This script does run but the map layer has "no bands to visualize".



  1. How can I visualize the bands? (Maybe the issue is that this dataset only has 1 band?).

  2. How can I add all 12 map layers, one per month? (perhaps with stacking?)


var ndvi = ee.ImageCollection('LANDSAT/LT5_L1T_32DAY_NDVI');

var months = ee.List.sequence(1, 12);


// Group by month, and then reduce within groups by mean();
// the result is an ImageCollection with one image for each
// month.
var byMonth = ee.ImageCollection.fromImages(
months.map(function (m) {
return ndvi.filter(ee.Filter.calendarRange(m, m, 'month'))
.select().median()
.set('month', m);
}));
print(byMonth);


Map.addLayer(ee.Image(byMonth.first()));


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...