1

I am working with MODIS-NDVI image collection in Google Earth Engine. Below, you can find a script which is creating a chart of NDVI values over the given period for particular location. I would like to print it as a table or text in Console/Panel, but could not find code for it. Is there anyway to do it?

var point = ee.Geometry.Point([10.455856189782935, 50.440969544991205]);

var image = ee.ImageCollection('MODIS/006/MOD13A1').
      filterDate('2018-01-01','2018-12-31')
        .select('NDVI');

var div_ndvi = function(image) {
  var NDVI_0 = image.select("NDVI");
  var NDVI_1 = NDVI_0.divide(10000);
  return image.addBands(NDVI_1);
};

var withN = image.map(div_ndvi);

print(withN);

var chart = ui.Chart.image.seriesByRegion(withN, point, ee.Reducer.first(), 'NDVI_1', 500);

print(chart)

1 Answer 1

1

You probably want the information in a list. You can do that using reduceRegion (to get the actual NDVI value at your geometry), add that as a property to each image and then extract those properties of all images in your collection using aggregate_array

// Make a 'table' in the console
var addNDVIatPoint = withN.map(function(image){
  return image.set(image.reduceRegion(ee.Reducer.first(), point))
})
// extract as 'table'
var table = ee.List(addNDVIatPoint.aggregate_array('NDVI_1'))
var datesMillis = ee.List(addNDVIatPoint.aggregate_array('system:time_start'))

print(table); print(datesMillis)

link script, where I also added how you could download a CSV table of the list you printed in the console

4
  • Thanks for solution. It works well. Can you please also assist me on finding command for printing out this list in panel. I have created panel and tried to add the list by writing "panel.add(table)". But, it did not work and I received a message "Only a ui.Widget can be added to a panel.". Commented Jan 25, 2019 at 16:44
  • 1
    Try something like this, or use evaluate() when implementing this on larger scripts to make sure your browser does not stop responding: Map.add(ui.Label(table.getInfo()))
    – Kuik
    Commented Jan 27, 2019 at 12:34
  • thank you for your suggestion. It worked well. But, it prints the data in horizontal axis when it is added to the panel. How can I make it vertically and with dates? Commented Jan 29, 2019 at 12:51
  • How can I make it vertically and with dates? Commented Feb 7, 2019 at 11:02

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.