1

I'm trying to create a chart of NDVI values that shows the average values for each day of the year for the last 5 years. I think exactly what I need is this: https://developers.google.com/earth-engine/guides/charts_image_collection#uichartimagedoyseriesbyregion

But if I insert a custom feature.collection with two points selected, it only shows one line in the chart, not two. What is the problem?

var pts = ee.FeatureCollection("users/petrjanos/hlavni/random_points");

// Load MODIS vegetation indices data and subset a decade of images.
var vegIndices = ee.ImageCollection('MODIS/006/MOD13A1')
                     .filter(ee.Filter.date('2010-01-01', '2020-01-01'))
                     .select(['NDVI', 'EVI']);

// Define the chart and print it to the console.
var chart = ui.Chart.image
                .doySeriesByRegion({
                  imageCollection: vegIndices,
                  bandName: 'NDVI',
                  regions: pts,
                  regionReducer: ee.Reducer.mean(),
                  scale: 500,
                  //yearReducer: ee.Reducer.mean(),
                  seriesProperty: 'label',
                  startDay: 1,
                  endDay: 365
                })
                .setOptions({
                  title: 'Average NDVI Value by Day of Year',
                  hAxis: {
                    title: 'Day of year',
                    titleTextStyle: {italic: false, bold: true}
                  },
                  vAxis: {
                    title: 'NDVI (x1e4)',
                    titleTextStyle: {italic: false, bold: true}
                  },
                  lineWidth: 5,
                  colors: ['f0af07', '0f8755', '76b349'],
                });
print(chart);

My feature collection: https://code.earthengine.google.com/?asset=users/petrjanos/hlavni/random_points

1 Answer 1

3

The problem is that in the ui.Chart.image.doySeriesByRegion, the seriesProperty argument is set to 'label'. However, that property does not exist in your FeatureCollection. Try changing it to a property that exists in your FeatureCollection such as 'id'.

var chart = ui.Chart.image
                .doySeriesByRegion({
                  imageCollection: vegIndices,
                  bandName: 'NDVI',
                  regions: pts,
                  regionReducer: ee.Reducer.mean(),
                  scale: 500,
                  // Here's the change
                  seriesProperty: 'id',
                  startDay: 1,
                  endDay: 365
                })
2
  • Thanks a lot! ..and one more question: if I use Landsat 8 data with filtering (clouds and shadows), can I get continuous lines and not just point like in the picture? imgur.com/C074rOo Jun 29, 2021 at 15:35
  • Hmm its hard to help without a reprex, I would suggest posting another question in SO about this issue. Jun 29, 2021 at 21:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.