0

I am new to GEE and don't know lots of concepts. I am trying to make a time-series chart of an image collection that I have reduced "Daily NASA Earth Exchange Global Climate Projections" from daily to monthly. I want the mean minimum temperature

var dataset_45 = ee.ImageCollection('NASA/NEX-GDDP')
                  .filterDate('2015-03-20', '2022-08-15')
                  .filter(ee.Filter.eq('scenario','rcp45'))
                  .filterBounds(geometry).select(['tasmin']);

This is how I convert from days to months, copied from another post

var tasmin_monthly = ee.List.sequence(0, (2022-2015)*12).map(function(n) {
  var start = ee.Date('2015-03-20').advance(n, 'month');
  var end = start.advance(1, 'month');
  return ee.ImageCollection('NASA/NEX-GDDP')
  .filterDate(start, end)
  .select(['tasmin'])
  .sum();
});

print(ee.ImageCollection(tasmin_monthly.flatten()));

When I make a ui.Chart.Image.Series() using this code

var tchart = ui.Chart.image.series(
                tasmin_monthly,
                geometry,
                ee.Reducer.mean(),
                27830 
              )
              .setChartType('LineChart')
              .setOptions({lineWidth: 3});
              // , colors: ['6b93ce','af6262']
print(tchart)

It gives me this error.

Error generating chart: No features contain non-null values of "system:time_start".

How do I fix it and is the daily to monthly conversion OK?

5
  • Need a little more information about the output you are expecting. When I read about the type of chart you're trying to make here, I am assuming you are trying to average tasmin both across the month and across your geometry, yielding a single monthly temperature value, then putting these values sequentially on a line chart. Is this correct?
    – Matt
    Aug 15, 2022 at 18:58
  • Yes, you are right. I want to plot a line chart (Month vs Mean temperature value) Aug 15, 2022 at 19:08
  • Furthermore, I have to ask whether the .sum() at the end of var tasmin_monthly is providing average value or not? Aug 15, 2022 at 19:13
  • .sum() is going to add all of the values together.
    – Matt
    Aug 15, 2022 at 19:22
  • Kindly suggest me to solve my line chart plotting error i.e. Month vs Mean temperature value. Aug 15, 2022 at 19:26

1 Answer 1

1

As far as initially filtering your data goes:

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

Start here. You don't need to filter by date since you do that in the next section. Filtering by boundaries doesn't do anything at this point, since each image is worldwide.

As far as producing your list of values goes:

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);
});

Your original code is calculating the monthly sum of temperature over the time period of March 2015 to March 2022, and is not incorporating the filtering for scenario rcp45. Now that the function is using dataset_45, it is filtering to scenario rcp45.

What this code yields is a list of mean temperatures, averaged across both month and your geometry. You can't use ui.Chart.Image.Series() to plot this because it's an array, not an image. You'll need ui.Chart.array.values(), which I do not have much experience with, hopefully someone else can finish the answer there, but this should put you on the right track.

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.