Sunday 20 August 2017

google earth engine - Error on GEE: No features contain non-null values of "system:time_start"



I'm calculating DVI over a region using MODIS. I am able to get the printout of the map properly but not the chart to retrieve the data. To calculate DVI, I did:


var dvi = img.expression(
'(nir - red)',
{
red: img.select('sur_refl_b01'), // 620-670nm, RED
nir: img.select('sur_refl_b02'), // 841-876nm, NIR
blue: img.select('sur_refl_b03') // 459-479nm, BLUE
.rename('DVI')
});


When I look at the inspector, I see the value for the DVI band, but the code for charting seems not to work. It says there's no system time.


var bandChart = ui.Chart.image.series(dvi, roi)

I also tried to add .filterDate ('2016-05-01', '2016-10-31') but it says the parameter is not a function. I.e.


var dvi = img.expression(
'(nir - red)',
{
red: img.select('sur_refl_b01'), // 620-670nm, RED
nir: img.select('sur_refl_b02'), // 841-876nm, NIR
blue: img.select('sur_refl_b03') // 459-479nm, BLUE

.rename('DVI')
});

I also tried to create a function (so as to specify timeframe) but that did not work either. How can I proceeed to get the chart?


var addDVI = function(image) {
var dvi = img.expression(
'(nir - red)',
{
red: img.select('sur_refl_b01'), // 620-670nm, RED
nir: img.select('sur_refl_b02'), // 841-876nm, NIR

blue: img.select('sur_refl_b03') // 459-479nm, BLUE
.rename('DVI')
.filterDate('2016-05-01', '2016-10-31')

});
return image.addBands (dvi);
};


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