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)?

You need to create (and start) a `ee.batch.Export.to*` task.

For your example, this would be something like:

``````slope_img = ee.Terrain.slope(ee.Image("USGS/SRTMGL1_003")).select("slope")
slope_fc = slope_img.reduceRegions(
collection=my_feature_collection,
reducer=ee.Reducer.mean(),
scale=30)

ee.batch.Export.table.toDrive(
collection = slope_fc,
Note that I used `reduceRegions` instead of `reduceRegion` since you mentioned you have many geometries, so ideally these are a feature collection (`my_feature_collection` in the example above).
• So the approach should be first to generate a feature collection object and then insert it into the desired function. Can the `ee.batch.Export` contain multiple functions? for example, slope and NDVI from Landsat? Or should I create 2 different `ee.batch.Export`? Dec 10, 2023 at 9:35
• It would help to understand what is your `GEE_polygon` (is it a multiPolygon?), but in my opinion it would be cleaner to have a FeatureCollection, where each feature is one polygon. The export task is in general to export images, tables, etc. I think you meant to ask if `reduceRegions` can handle multiple bands, and the answer is yes. The example above used only one band ("slope") but in general it can reduce all bands in your image. Dec 10, 2023 at 11:06
• GEE_polygon is one polygon created with `ee.Geometry.Polygon` function. What I meant to ask is what would be the approach when I need statistics from several datasets per polygon in the FeatureCollection. For example, for each polygon I would like to get the average slope, the monthly average rain for 2023, and the average NDVI calculated from Landsat 8 for 2021-2023. Do I need to generate three `ee.batch.Export`, one for the slope, one for the rain, and one for the NDVI or can I somehow include all three in one `ee.batch.Export` job? Dec 10, 2023 at 11:44