I have 2 shapefiles representing different types of land-use. Each Shapefile contains 10 polygons. I would like to chart the mean NDVI value over a specific timespan for each class. How can I display 2 FeatureCollection in the same chart?

I tried .flatten(), but then the chart displays only 1 graph.

var L8 = ee.ImageCollection("LANDSAT/LC8_L1T_TOA"),
extensiv = ee.FeatureCollection("users/tobkugler/Engadin_Extensive_Merc_new"),
intensiv = ee.FeatureCollection("users/tobkugler/Engadin_Intensiv_Merc_new");

var classes = new ee.FeatureCollection([extensiv,intensiv]);
var classes_flatten = classes.flatten();

// Timespan for the ImageCollection

 var filtered = L8.filterDate('2014-01-01', '2016-12-31')

// Function to add NDVI band

function addNDVI(image) {
var ndvi = image.normalizedDifference(['B5', 'B4']);
return image.addBands(ndvi);
var with_ndvi = filtered.map(addNDVI);

//Print NDVI Chart

 var chart = ui.Chart.image.doySeriesByRegion(with_ndvi,'nd',classes_flatten,

   // use ui.Chart.image.seriesByRegion
var chart = ui.Chart.image.seriesByRegion(with_ndvi, classes_flatten, 
                ee.Reducer.mean(), 'nd',
               30, 'system:time_start', 'label')
  • Welcome to GIS SE. As a new user, please take the Tour. Answers to coding questions are expected to contain both code and text, to provide context, explanation, and often a link to documentation. – Vince Sep 5 '18 at 23:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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