1

I am working with GLDAS-2.1 image collection. I would like to generate a daily image collection with max temperature, min temperature, mean temperature and sum temperature for each day from 3 hourly temperature data. Please, see below developed script. I need a help on improving it as when I run it gives an error:

ERROR .

// Start and End Dates
var inidate = ee.Date.fromYMD(2010,1,1)
var enddate = ee.Date.fromYMD(2020,1,1)

// Difference between start and end in days 
var difdate = enddate.difference(inidate, 'day')

// Import GLDAS data
var gldas_col = ee.ImageCollection('NASA/GLDAS/V021/NOAH/G025/T3H')
.filterDate(inidate, enddate)
.select('Tair_f_inst');

// Time lapse
var lapse = ee.List.sequence(0, difdate.subtract(1))
var inidate = ee.Date('2010-01-01')
var listdates = lapse.map(function(day){
  return inidate.advance(day, 'day')
})

// Function over a image collection
var new_coll = ee.ImageCollection(listdates.map(function(day){
  day = ee.Date(day);

  var max_collection = gldas_col.filterDate(day, day.advance(1, 'day')).max().clip(aoi)
  return max_collection.rename('max_Temp').set(day.format('YYYY-MM-dd'))

  var min_collection = gldas_col.filterDate(day, day.advance(1, 'day')).min().clip(aoi)
  return min_collection.rename('min_Temp').set(day.format('YYYY-MM-dd')) 

  var mean_collection = gldas_col.filterDate(day, day.advance(1, 'day')).mean().clip(aoi)
  return mean_collection.rename('mean_Temp').set(day.format('YYYY-MM-dd')) 

  var sum_collection = gldas_col.filterDate(day, day.advance(1, 'day')).mean().clip(aoi)
  return sum_collection.rename('sum_Temp').set(day.format('YYYY-MM-dd')) 

}));

print(new_coll.filterDate('2010-01-01', '2010-02-01'));

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.