[GIS] Charting two FeatureCollections in Google Earth Engine

google-earth-engine

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')
.filterBounds(extensiv);   

// 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,
 ee.Reducer.mean(),30,ee.Reducer.mean(),'label');

 print(chart);

Best Answer

   // use ui.Chart.image.seriesByRegion
var chart = ui.Chart.image.seriesByRegion(with_ndvi, classes_flatten, 
                ee.Reducer.mean(), 'nd',
               30, 'system:time_start', 'label')
                .setChartType('ScatterChart'));
Related Question