1

Suppose I run the following code to get an ImageCollection in Google Earth Engine:

collection = ee.ImageCollection("ECMWF/ERA5_LAND/HOURLY").select("total_precipitation")
collection = collection.filterDate("2020-01-01", "2020-01-02")
print(collection.size().getInfo())

This outputs 24, because the data is hourly and it is a collection of images for 1 day. If I then run the following code to inspect the first image:

geometry = ee.Geometry.Polygon([
    (-119.6863362607843, 37.91032228872993),
    (-119.24681336572189, 37.91032228872993),
    (-119.24681336572189, 37.58602618425783),
    (-119.6863362607843, 37.58602618425783),
    (-119.6863362607843, 37.91032228872993)
])

img = collection.first()
count = img.reduceRegion(ee.Reducer.count(), geometry=geometry, scale=1000)
count.getInfo()

This outputs:

{'total_precipitation': 540}

Which I believe means there are 540 pixel values in that band's image for that region.

How would I go about getting a single composite image for the whole day's data, which is an average of the 24 hourly values? To clarify: from the ImageCollection above I want to produce a single Image with 540 pixel values, where each value is the mean of the 24 hourly values. Is this possible?

1 Answer 1

1

It's unclear what you mean by "the underlying hourly images each have the same dimensions (in this case 4x6 pixels)". Each total_precipitation band in the ECMWF/ERA5_LAND/HOURLY collection contains a single value per pixel. There are 24 images per day, but they don't have a 4x6 structure; just one value per hour. When you take the mean of those, you end up with a single value for the whole day.

4
  • I mean that when I download each hourly image separately for that particular region and convert to an array, it has dimensions 4x6 pixels
    – Toby Petty
    Oct 19, 2022 at 13:06
  • @TobyPetty Please revise your question with any clarifications that may be useful for potential answerers.
    – PolyGeo
    Oct 19, 2022 at 21:26
  • Apologies for the confusion, I think my original question was not worded very clearly. I've tried rewriting the question to be more straightforward, hopefully it's clear what I'm asking now - please let me know if not.
    – Toby Petty
    Oct 20, 2022 at 3:44
  • Will delete this questions as got an answer.
    – Toby Petty
    Oct 20, 2022 at 21:42

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.