I am trying to convert a list of images in GEE to an image collection, then get the mean and export the results. However, the code I have doesn't seem to work. The error when exporting the image is Image.clip: The geometry for image clipping must be bounded.
However, I can both view an individual image from the list and the mean image.
Here is the code.
import ee
import folium
import time
import webbrowser
ee.Initialize()
region = "Romania"
start_date = '2023-01-01' # initial date of interest (inclusive)
end_date = '2023-12-31' # final data of interest (exclusive)
band = "total_precipitation_sum"
folder = "Romania"
outname = "Romania_total_precip"
# Get a feature collection of administrative boundaries and filter by country
countries = ee.FeatureCollection('FAO/GAUL/2015/level0').select('ADM0_NAME')
region = countries.filter(ee.Filter.eq('ADM0_NAME', 'Romania'))
region_list = region.toList(region.size()) # klugey
region = ee.Image(region_list.get(0))
### get weather image collection
weatherData = ee.ImageCollection("ECMWF/ERA5_LAND/DAILY_AGGR").filter(ee.Filter.date("2023-01-01", "2023-12-31")).map(lambda image: image.clip(region.geometry()))
precip = weatherData.select(band)
precip_list = precip.toList(precip.size())
image_from_list = ee.Image(precip_list.get(0)).multiply(1000)
task = ee.batch.Export.image.toDrive(
image = image_from_list,
description = "RomanianPrecip1",
folder = folder,
region = image_from_list.geometry()
)
task.start()
status = None
while status != 'COMPLETED':
status = task.status()['state']
time.sleep(30) ## wait 60 seconds if not completed
print(task.status())
Precip_coll = ee.ImageCollection.fromImages(precip_list)
Precip_mean = Precip_coll.mean().multiply(1000)
task = ee.batch.Export.image.toDrive(
image = Precip_mean,
description = "RomanianPrecip_mean",
folder = folder,
region = Precip_mean.geometry()
)
task.start()
status = None
while status != 'COMPLETED':
status = task.status()['state']
time.sleep(30) ## wait 60 seconds if not completed
print(task.status())
Both images can be displayed in folium, so not sure what the problem is.