0

I'm trying to aggregate hourly data from ERA5 land to daily data over a specific shapefile in GEE. In theory my code is working, however, the output gives the same amount of evaporation for the entire time series.

Here is my code: https://code.earthengine.google.com/014c446c0d21091096cf603de7b9df87

Note: I split the data into monthly subsets because GEE gave errors when I was trying bigger subsets.

EDIT the orginal code:

// prepare geometries
var basin = basin.first().geometry();
var watershed = watershed.first().geometry();
var water = [ee.Feature(basin, {'label': 'basin'}),
          ee.Feature(watershed, {'label': 'watershed'})];
var features = ee.FeatureCollection(water);

// prepare time dimension and main data source
var startDate = ee.Date('1989-11-01');
var endDate = ee.Date('2021-01-01');
var collection = ee.ImageCollection("ECMWF/ERA5_LAND/HOURLY")
              .filterDate(startDate, endDate)
              .filterBounds(basin)
              .select('total_evaporation');
// split into smaller time ranges
var startDate1 = ee.Date('1990-01-01');
var endDate1 = ee.Date('1990-03-01');
var era5Collection1 = collection.filterDate(startDate1, endDate1);

// aggregate imagecollection to daily data
//var numberOfDays = endDate.difference(startDate, 'days')
var numberOfDays1 = endDate1.difference(startDate1, 'days');

var daily1 = ee.ImageCollection(
              ee.List.sequence(0, numberOfDays1.subtract(1))
             .map(function (dayOffset) {
    var start = startDate1.advance(dayOffset, 'days');
    var end = start.advance(1, 'days');
    return era5Collection1
       .filterDate(startDate1, endDate1)
       .sum()
       .set('system:time_start', start.millis());
      })
);

var chart1 = ui.Chart.image.seriesByRegion(daily1, features, 
ee.Reducer.sum(), 'total_evaporation', 200, 'system:time_start', 
'label')
          .setChartType('ScatterChart');
print(chart1);
1
  • Please add the code to the question. Links tend to break and with it also the usefullness of questions (and answers)
    – JonasV
    Jul 21, 2021 at 7:58

1 Answer 1

1

You've used the wrong variables in line 77

var daily1 = ee.ImageCollection(
  ee.List.sequence(0, numberOfDays1.subtract(1))
    .map(function (dayOffset) {
      var start = startDate1.advance(dayOffset, 'days');
      var end = start.advance(1, 'days');
      return era5Collection1
        .filterDate(startDate1, endDate1)
        .sum()
        .set('system:time_start', start.millis());
    })
);

.fiterDate(startDate1, endDate1) should be .fiterDate(start, end)

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.