1

I am trying to extract NDVI values by regions of a certain polygon shapefile. I need, as output a graph (or a table) where the regions are defined by a certain column, called 'FID_incend'. I need exactly this column because those are unique values that I will use afterwards to process other maps.

My code is:

var incendis1987 = ee.FeatureCollection("users/oriolbaena/incendis1987_identityLitology_87929702_s_0p9HA_simplified");

Map.centerObject(incendis1987, 12);
Map.addLayer (incendis1987,{color: 'FF0000'})

var addNDVI = function (image){
  var ndvi= image.normalizedDifference(['B4', 'B3']).rename('NDVI');
  return image.addBands(ndvi)
};

var dataset = ee.ImageCollection("LANDSAT/LT05/C01/T1_SR")
    .filterBounds(incendis1987)
    .filterDate('1984-01-01', '1995-12-31')
    .map(addNDVI).select('NDVI');


var graph = ui.Chart.image.seriesByRegion({
imageCollection: dataset.select('NDVI'), 
regions: incendis1987,
reducer: ee.Reducer.mean(),
scale: 30,
seriesProperty: FID_incend,
})
  .setChartType('ScatterChart')
  .setOptions({title: 'NDVI Incendis1987 dates1984-1995', vAxis: {title:'NDVI'}, 
             lineWidth: 1,pointSize: 2,});
print(graph)
print ('I love JavaScript (L)')

As you can see, attibutes of my table include the column 'FID_incend': enter image description here

The shp can be found here: https://code.earthengine.google.com/?asset=users/oriolbaena/incendis1987_identityLitology_87929702_s_0p9HA_simplified

4

1 Answer 1

0

Found your bug. It is so small, it is easy to overlook.

your seriesProperty isn't in "quotes". Modify your code in your ui.Chart.image.seriesByRegion() function dictionary. so that the series property is in quotes. It should work.

seriesProperty: "FID_incend",

NDVI graph

1
  • Sorry don't know how to add a picture in a comment! I posted another answer! Commented Oct 15, 2019 at 9:36

Your Answer

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

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