1

I have reduced a band/variable of daily image collection to monthly collection. The function returns a list containing objects with 2 properties. Like this enter image description here

I want to plot a time-series chart of all the elements (n=90) with date value on x-axis and tasmin on Y-Axis.

Which chart type should I use and how to obtain this in code?

This is my code

// load data
var dataset_45 = ee.ImageCollection('NASA/NEX-GDDP')
                  .filter(ee.Filter.eq('scenario','rcp45'))
                  .select(['tasmin']);




var tasmin_monthly = ee.List.sequence(0, 89).map(function(n){
  var start = ee.Date('2015-03-20').advance(n, 'month');
  var end = start.advance(1, 'month');
  var monthtemp =  dataset_45.filterDate(start, end)
                      .mean()
                      .reduceRegion({
                      reducer: 'mean',
                      geometry: geometry,
                      scale: 27830
                      });
  return monthtemp.set('system:time_start', start);
});

print(tasmin_monthly);
var min = tasmin_monthly.get(0)
print(min)

1 Answer 1

2

You can turn your list into a FeatureCollection and then chart it:

var tasmin_monthly = ee.FeatureCollection(
  ee.List.sequence(0, 89).map(function(n) {
    var start = ee.Date('2015-03-20').advance(n, 'month')
    var end = start.advance(1, 'month')
    var monthtemp = dataset_45.filterDate(start, end)
      .mean()
      .reduceRegion({
        reducer: 'mean',
        geometry: geometry,
        scale: 27830
      })
    return ee.Feature(null, monthtemp)
      .set('system:time_start', start)
  })
)

print(tasmin_monthly)

var chart = ui.Chart.feature.byFeature({
  features: tasmin_monthly, 
  xProperty: 'system:time_start', 
  yProperties: ['tasmin']
})

print(chart)

https://code.earthengine.google.com/4dab71a796cc729b672c83bfe17fdcdd

1
  • Thank you Daniel, it worked
    – user173819
    Aug 16, 2022 at 10:44

Your Answer

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

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