In Google Earth Engine Compute Units (EECUs) There are two kinds of EECUs: “Batch” and “Online.” Batch EECUs are typically used for very large jobs (for example, exports), and online EECUs provide near-real-time responses in the Code Editor, apps, etc. (from here)
I would like to use Batch EECU with Python API. The usecase is this: I have many polygons and I would like to calculate the average slope for each polygon. To calculate the average slope of a single polygon (using Python API) I used:
average_slope = ee.Terrain.slope(ee.Image("USGS/SRTMGL1_003")).reduceRegion(
reducer=ee.Reducer.mean(),
geometry=GEE_polygon,
scale=30
).getInfo()['slope']
To calculate the average slope of many polygons I use a loop and execute the above code for each polygon, however, doing that is considered "online EECU".
How can I perform this task using Batch EECU (in Python)?
Best Answer
You need to create (and start) a
ee.batch.Export.to*
task.For your example, this would be something like:
Note that I used
reduceRegions
instead ofreduceRegion
since you mentioned you have many geometries, so ideally these are a feature collection (my_feature_collection
in the example above).