I need to perform the same analysis for different geometry points and plot it. Actually I have the plot for each point and when I click on the map creates a chart for the point where I clicked it but when I click another point, deletes the actual chart and creates another one. There is a way to add an extra series to the chart of the values when I click the point instead of deleting and creating another one?

Here is my code:

var panel = ui.Panel();
panel.style().set('width', '600px');
var intro = ui.Panel([
  ui.Label({value: 'NDVI Chart Inspector',
    style: {fontSize: '20px', fontWeight: 'bold'}  }),
  ui.Label('Click a point on the map to inspect.')]);
var lon = ui.Label();
var lat = ui.Label();
panel.add(ui.Panel([lon, lat], ui.Panel.Layout.flow('horizontal')));
Map.onClick(function(coords) {
  Map.layers().set(1, dot);
  lon.setValue('lon: ' + coords.lon.toFixed(5)),
  lat.setValue('lat: ' + coords.lat.toFixed(5));
  var geometry = ee.Geometry.Point(coords.lon, coords.lat)

//analysis around the point...

var ndvi_chart = ui.Chart.array.values({array: smooth_ndvi, axis: 0, xLabels: difference})
      title: 'NDVI Dry season 2023',
      colors: ['green'],
      hAxis: {'title': 'Days since Dry Season Started'},
      vAxis: {'title': 'NDVI'},
      pointSize: 0,
      lineWidth: 2,
      legend: {position: 'none'}

  panel.widgets().set(2, ndvi_chart);

Map.style().set('cursor', 'crosshair');
ui.root.insert(0, panel);    

Smooth NDVI list is created for each point. Is there a way to add that list to the chart of the previous point that I click?


Your Answer

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