Open-EO / openeo-python-client

Python client API for OpenEO
https://open-eo.github.io/openeo-python-client/
Apache License 2.0
156 stars 42 forks source link

Inconsistent and non-standard CRS handling for geometry arguments in DataCube #671

Open soxofaan opened 5 days ago

soxofaan commented 5 days ago

stumbled on this while working on #104: https://github.com/Open-EO/openeo-python-client/blob/5a3e6f40cf5945ea885165db9845587435be66f0/openeo/rest/datacube.py#L1074-L1087

e.g. public facing from cube.aggregate_spatial(..., crs=...) and cube.mask_polygon(..., srs=...)

This CRS handling has some problems:

I think we should get rid of this

soxofaan commented 5 days ago

related discussions and threads:

soxofaan commented 5 days ago

As far as I understand the threads above, the "crs" support mentioned above was originally targeted to the use case where the geometry is provided as shapely object (which has no explicit CRS info), which has to be converted to GeoJSON to be embedded in the process graph. Over time, a lot more geometry value types for geometries were added (e.g UDP parameters, vector cubes, load_url, ...), where it's impossible to attach that CRS to, so we now have a very inconsistent CRS handling situation.

soxofaan commented 5 days ago

proposed solution:

So use cases that wanted to use shapely geometries with custom crs the old way:

cube = cube.aggregate_spatial(
    geometries=shapely_geometry,
    crs="EPSG:123456",
    ...
)

would have to change to something like

cube = cube.aggregate_spatial(
    geometries=shapely_to_geojson(shapely_geometry,  crs="EPSG:123456"),
    ...
)
jdries commented 5 days ago

I would: