Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

apply_polygon (previously known as chunk_polygon) abuses MultiPolygon as collection of polygons in its internal API #288

Open
soxofaan opened this issue Jun 7, 2024 · 1 comment · May be fixed by Open-EO/openeo-geopyspark-driver#801 or #291
Assignees

Comments

@soxofaan
Copy link
Member

soxofaan commented Jun 7, 2024

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 :

# 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

@soxofaan
Copy link
Member Author

soxofaan commented Jun 7, 2024

related to (or causing) this confusion: the apply_polygon process should use argument geometries instead of polygons -> Open-EO/openeo-processes#511

soxofaan added a commit that referenced this issue Jun 7, 2024
@soxofaan soxofaan changed the title apply_polygon (previously known as chunk_polygon) abuses MultiPolygon as collection of polygons in it's internal API apply_polygon (previously known as chunk_polygon) abuses MultiPolygon as collection of polygons in its internal API Jun 7, 2024
JeroenVerstraelen added a commit to Open-EO/openeo-geopyspark-driver that referenced this issue Jun 9, 2024
@JeroenVerstraelen JeroenVerstraelen self-assigned this Jun 17, 2024
soxofaan added a commit that referenced this issue Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment