Open-EO / openeo-geopyspark-driver

OpenEO driver for GeoPySpark (Geotrellis)
Apache License 2.0
25 stars 4 forks source link

array-to-array reducer support in `aggregate_spatial` #726

Open soxofaan opened 3 months ago

soxofaan commented 3 months ago

From https://discuss.eodc.eu/t/how-to-use-quantiles-on-a-2d-data-cube-x-y/703 I learned that the VITO backend supports array-to-array reducers in aggregate_spatial for example as documented at https://open-eo.github.io/openeo-python-client/basics.html#computing-multiple-statistics

Some issues

cube = con.load_collection(
    "SENTINEL2_L2A",
    temporal_extent=["2023-09-05", "2023-09-12"],
    bands=["B02", "B03"]
)
geometry = shapely.geometry.box(3, 51, 3.001, 51.001)

from openeo.processes import array_create
aggregations_multiple = cube.aggregate_spatial(
    geometries=geometry, 
    reducer=lambda data: array_create([data.mean(), data.median(), data.count()]),
)
aggregations_multiple.download("forum703-multiple.json")

results in something like

{
  "2023-09-05T00:00:00Z": [[280.33, 230, 84, 613.44, 565, 84]],
  "2023-09-07T00:00:00Z": [[410, 364, 84, 691.833, 634, 84]],
  "2023-09-10T00:00:00Z": [[621.2857, 584, 84, 863.1071, 833, 84]]
}