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.
Polygonize collects all possible polygons:
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.