I want to create multiple charts from NDVI data and name them per location. but when I want to display the chart title, the location cannot be defined. Where does the error lie?

//Point known locations for NDVI
var p1 = ee.Feature(
    ee.Geometry.Point(115.57539510901834, -2.362381045840717), {'label': 'SCM_I5I6_2022-01'});
var p2 = ee.Feature(
    ee.Geometry.Point(115.576489, -2.363431), {'label': 'SCM_I5I6_2022-02'});
var union1 = ee.FeatureCollection([p1, p2],{'name': 'SCM_I5I6_2022'});

var p3 = ee.Feature(
    ee.Geometry.Point(115.596284, -2.349884), {'label': 'SCM_F10B_2022'});
var union2 = ee.FeatureCollection([p3],{'name': 'SCM_F10B_2022'});

var p4 = ee.Feature(
    ee.Geometry.Point(115.597183, -2.349885), {'label': 'SCM_F10_2022-01'});
var p5 = ee.Feature(
    ee.Geometry.Point(115.597184, -2.348981), {'label': 'SCM_F10_2022-02'});
var union3 = ee.FeatureCollection([p4, p5],{'name': 'SCM_F10_2022'});

var p6 = ee.Feature(
    ee.Geometry.Point(115.604485, -2.341752), {'label': 'SCM_D12_2023-01'});
var p7 = ee.Feature(
    ee.Geometry.Point(115.603486, -2.340847), {'label': 'SCM_D12_2023-02'});
var p8 = ee.Feature(
    ee.Geometry.Point(115.604386, -2.339944), {'label': 'SCM_D12_2023-03'});
var union4 = ee.FeatureCollection([p6, p7,p8],{'name': 'SCM_D12_2023'});

var p9= ee.Feature(
    ee.Geometry.Point(115.604385, -2.340848), {'label': 'SCM_D12_2022'});
var union5 = ee.FeatureCollection([p9],{'name': 'SCM_D12_2022'});

var p10= ee.Feature(
    ee.Geometry.Point(115.604387, -2.339039), {'label': 'SCM_C12/D12_2023'});
var union6 = ee.FeatureCollection([p10],{'name': 'SCM_C12/D12_2023'});

// Map a function over Sentinel 2 collection to add an NDVI band.
var withNDVI = s2.map(function(image) {
  var ndvi = image.normalizedDifference(['B8', 'B4']).rename('NDVI');
  return image.addBands(ndvi);
var geom = [union1, union2, union3, union4, union5, union6];
for (var i=0; i<geom.length; i++){
  var tempTimeSeries = ui.Chart.image.seriesByRegion({
    imageCollection: withNDVI.select('NDVI'),
    regions: geom[i],
    reducer: ee.Reducer.mean(),
    scale: 200,
    xProperty: 'system:time_start',
    seriesProperty: 'label'
    title: 'Average NDVI Table ' + geom[i].getInfo().features[0].properties['name'],
    hAxis: {title: 'Date', titleTextStyle: {italic: false, bold: true}},
    vAxis: {
      title: 'Index'
    lineWidth: 1,
    pointSize: 4,
    series: {
      0: {color: COLOR.RED},
      1: {color: COLOR.GREEN},
      2: {color: COLOR.BLUE},
      3: {color: COLOR.YELLOW},
      4: {color: COLOR.PINK},
      5: {color: COLOR.BLACK},
      6: {color: COLOR.PURPLE},
      7: {color: COLOR.AQUA}
var points = [union1,union2,union3,union4,union5,union6];
for (var j =0;j<points.length;j++){
  Map.addLayer(points[j], {color: COLOR.PURPLE}, 'Points');


  • Do you want to use the name of the FeatureCollection or the label of the first Feature as the chart title? Currently you're trying to use the name of the first Feature, but your features don't have that property which is why you're getting undefined. Your feature collections also don't have a name property because you're not setting them quite right - try using the set method instead of passing the properties into the constructor. Feb 3 at 4:49
  • where i can place set method? Feb 3 at 5:04

1 Answer 1


To set the name property of each FeatureCollection, you'll need to use the set method instead of passing the properties into the constructor. For example:

var union1 = ee.FeatureCollection([p1, p2]).set({'name': 'SCM_I5I6_2022'};

Next, you're currently setting the chart title based on the properties of the feature instead of the collection. To use the collection instead, try:

title: 'Average NDVI Table ' + geom[i].getInfo().properties['name']
  • its work sir. thank you very much Feb 3 at 5:20

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.