Sunday, 23 September 2018

modis - DOY chart in Google Earth Engine


With the following code I am trying to produce a NDVI graph with the days of the year on the x axis (based on this example, 2nd graph).


var modisNDVI = ee.ImageCollection ('MODIS/MCD43A4_006_NDVI');
var modiscollection = ee.ImageCollection (modisNDVI.filterDate('2007-05-01','2011-09-30'));
var clip=modiscollection.mean().clip(region);
var chart = ui.Chart.image.doySeriesByYear(
clip, 'NDVI', region, ee.Reducer.mean(), 500);


print(chart);

Map.addLayer (clip, {min:0.0,max:1,palette:['FFFFFF','CC9966','CC9900','996600','33CC00','009900','006600','000000']},'NDVI');

From this, I get the following error and as a new user, I can't understand it.


P.S. For the region I just draw a polygon


Error :


Collection.first: Error in map(ID=0):
Date: Parameter 'value' is required.

Answer




ui.Chart.image.doySeriesByYear function takes as argument an ImageCollection but when you do var clip=modiscollection.mean().clip(region); you are converting the collection to an image, so the argument you pass to the function is an ee.Image, do:


var modisNDVI = ee.ImageCollection ('MODIS/MCD43A4_006_NDVI');
var modiscollection = ee.ImageCollection (modisNDVI.filterDate('2007-05-01','2011-09-30'));

var chart = ui.Chart.image.doySeriesByYear(
modiscollection, 'NDVI', region, ee.Reducer.mean(), 500);

print(chart);

var clip = modiscollection.mean().clip(region);

Map.addLayer (clip, {min:0.0,max:1,palette:['FFFFFF','CC9966','CC9900','996600','33CC00','009900','006600','000000']},'NDVI');

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...