Deltares / xugrid

Xarray and unstructured grids
https://deltares.github.io/xugrid/
MIT License
61 stars 8 forks source link

Methods: polygonize and bounding_polygon are incomplete for non-contiguous 2d topologies #156

Open Huite opened 1 year ago

Huite commented 1 year ago

Polygonize collects all possible polygons:

        collection = shapely.polygonize(shapely.linestrings(coordinates[edges]))
        polygon = max(collection.geoms, key=lambda x: _bbox_area(x.bounds))

This will work as desired with holes and such, but not if there e.g. two non-contiguous part of the mesh.

The correct check here would be to find the largest bounding boxes that are not contained by any other. Arguably the return object should be a MultiPolygon.