0

I am hoping to obtain monthly averages for NDVI derived from Landsat data and then produce a line chart.

I have succeeded in cloudmasking Landsat 8 and adding an NDVI band.

Working with code suggested in another post I was able to create an image collection with one NDVI value per month for 5 years.

Now however, when I try and chart this image collection there is no "system:time_start" available so I cannot produce a time series.

Any help would be appreciated. Maybe I have to go about calculating the monthly mean NDVI values in a different way.

My code is below.

https://code.earthengine.google.com/7c0abe5c696a4aa246647f4b34e2f48c

1 Answers1

1

This can be fixed by simply replacing the line .set('month', m).set('year', y) by .set('system:time_start', ee.Date.fromYMD(y, m, 1)) in your function calculating byMonthYear.

Using mean() method (or other reducing methods such as median(), max(), etc.) on ImageCollection would result in the loss of all image's properties including system:time_start. This is fairly reasonable as Google Earth Engine has no idea from which image it should take properties.

The above fix just manually adds system:time_start property back to the mean image. This property should hold a ee.Date object (I just made it the first day of the month).

Kevin
  • 338
  • 1
  • 3
  • 9