-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Open-EO/openeo-geopyspark-driver
#801Labels
Description
Stumbled on this while working on #287:
The apply_polygon process implementation (originally added as chunk_polygon in a411109) coerces the provided geometries into a MultiPolygon :
openeo-python-driver/openeo_driver/ProcessGraphDeserializer.py
Lines 859 to 874 in ea078ff
| # TODO: this logic (copied from original chunk_polygon implementation) coerces the input polygons | |
| # to a single MultiPolygon of pure (non-multi) polygons, which is conceptually wrong. | |
| # Instead it should normalize to a feature collection or vector cube. | |
| if isinstance(polygons, DelayedVector): | |
| polygons = list(polygons.geometries) | |
| for p in polygons: | |
| if not isinstance(p, shapely.geometry.Polygon): | |
| reason = "{m!s} is not a polygon.".format(m=p) | |
| raise ProcessParameterInvalidException(parameter="polygons", process="apply_polygon", reason=reason) | |
| polygon = MultiPolygon(polygons) | |
| elif isinstance(polygons, shapely.geometry.base.BaseGeometry): | |
| polygon = MultiPolygon(polygons) | |
| elif isinstance(polygons, dict): | |
| polygon = geojson_to_multipolygon(polygons) | |
| if isinstance(polygon, shapely.geometry.Polygon): | |
| polygon = MultiPolygon([polygon]) |
and pushes this API through into geopyspark driver, e.g.
https://github.com/Open-EO/openeo-geopyspark-driver/blob/1f22c0da34535e986908480673ad341c9f89324d/openeogeotrellis/geopysparkdatacube.py#L572-L575
MultiPolygon should not be abused as a collection of polygons. Instead the API should use something like a FeatureCollection or vector cube abstraction