1

I am trying to calculate the monthly min and max temperatures averaged over my AOI using the ECMWF hourly temperature at 2m height data (https://developers.google.com/earth-engine/datasets/catalog/ECMWF_ERA5_LAND_HOURLY).

However, I keep getting the following error:

Air temperature [K] at 2m height: Tile error: User memory limit exceeded (x12). 

I am aware this is probably due to the large amount of images that are being processed but not sure the best way to solve the issue. Is it best to first aggregate by day, then by month?

Here is the link to the code: https://code.earthengine.google.com/9814dbb841e27f3b991e780e21f13a1f

Please find a link to my AOI asset here: https://code.earthengine.google.com/?asset=users/josefhclifford/GreaterKapoetaPayams

1 Answer 1

2

Your AOI asset wasn't shared, so I had to test this with a random area. By looking at your code, the biggest issue I see is the sorting. It's an expensive operation that you don't need.

Here's my stab at a script calculating the monthly averages. This still might fail for your actual AOI - no way for me to tell.

var aoiCollection = ee.FeatureCollection([
  ee.Feature(ee.Geometry.Point([0, 10]).buffer(100000).bounds(), {ADM3_EN: 'Some region'})
])
var startDate = ee.Date('1981-01-01')
var endDate = ee.Date('2022-01-01')

var temperatureCollection = ee.ImageCollection("ECMWF/ERA5_LAND/HOURLY")
  .filterDate(startDate, endDate)
  .filterBounds(aoiCollection.geometry())
  .select('temperature_2m')

var monthOffsets = endDate
  .difference(startDate, 'months')
  .subtract(1)
var dateCollection = ee.FeatureCollection(
  ee.List.sequence(0, monthOffsets)
    .map(function (monthOffset) {
      var date = startDate
        .advance(ee.Number(monthOffset), 'months')
      return ee.Feature(null, {date: date})
    })
)

var monthlyMinMax = dateCollection
  .map(function (dateFeature) {
    var date = ee.Date(dateFeature.get('date'))
    var minMax = ee.Image(
      temperatureCollection
        .filterDate(date, date.advance(1, 'month'))
        .reduce(ee.Reducer.minMax())
      )
    return minMax
      .reduceRegions({
        collection: aoiCollection,
        reducer: ee.Reducer.mean()
          .combine(ee.Reducer.count(), null, true)
          .combine(ee.Reducer.min(), null, true)
          .combine(ee.Reducer.max(), null, true)
          .combine(ee.Reducer.stdDev(), null, true),
        scale: 11132
      })
      .map(function (feature) {
        return feature.set({
          year: date.get('year'),
          month: date.get('month'),
        })
      })
      .filterMetadata('temperature_2m_max_count', "not_equals", 0)
  })
  .flatten()

print(monthlyMinMax)
Map.centerObject(aoiCollection)
Map.addLayer(aoiCollection)

https://code.earthengine.google.com/b2763c1b8d11add95295e187e7493558

3

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.