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?