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);
};