Aggregate_spatial

Hi,
I want to extract the indices information from the datacube. The “aggregate_spatial” functions works well when i feed the centroids points of polygons. However, it shows an error when a multipolygon is passed directly in geoJSON format.

C1_map= S2_2018_input.aggregate_spatial(polygon, reducer=“mean”).execute()
C1_map.dowload(“c1map.csv”)
I want to extract the information on pixel level masked by polygon. Are there any specific processes or UDFs that should look upon?

Hi,
can you share the actual error and/or job id?

The code looks fine, but question is what that ‘polygon’ object looks like. In general, MultiPolygon should be supported.

To extract pixels, I would however use filter_spatial with your polygon, and then store to netcdf. There is also the ‘sample_by_feature’ option that makes it work for storing multiple polygon to multiple netcdfs:

https://open-eo.github.io/openeo-python-client/cookbook/sampling.html#dataset-sampling

Are you by any chance trying to pass a string with GeoJSON content in that aggregate_spatial(polygon) call?

Worked. Thank You Jeroen.

Related: DataCube.aggregate_spatial(geometry) in the python client allows to pass the geometry as a string, which might give the impression that a geosjon dump can be given (while it is actually interpreted as a backend-side path). We should probably change that or at least provide some client-side checks: Smarter geometry loading from `DataCube.aggregate_spatial` · Issue #581 · Open-EO/openeo-python-client · GitHub