Repository navigation
MultiPolygons with holes are broken #333
Description
Activity
- addedbugSomething isn't workingSomething isn't workingshapes 🫧Anything related to ShapesAnything related to Shapes
on Aug 28, 2024 - linked a pull request that will close this issueDonut-MultiPolygons are now correctly rendered again #334
on Aug 28, 2024 Hi @timtreis,
With the latest
spatialdata-plotversion, I still have issues displaying holes. Is it expected?from shapely import Polygon from geopandas import GeoDataFrame from spatialdata import SpatialData from spatialdata.models import ShapesModel import spatialdata_plot ext = [(0, 0), (0, 1), (1, 1), (1, 0), (0, 0)] interior = [(0.1, 0.1), (0.1, 0.9), (0.9, 0.9), (0.9, 0.1), (0.1, 0.1)] polygon = Polygon(ext, [interior]) geo_df = GeoDataFrame(geometry=[polygon]) sdata = SpatialData(shapes={"test": ShapesModel.parse(geo_df)}) sdata.pl.render_shapes("test").pl.show()
While the polygon should look like this:
No, and our testing should've caught that. I'll investigate. Thanks for reporting!
Reacted by Quentin BlampeyWait, you're initialising this as a Shapely.Polygon. Try again with Shapely.MultiPolygon
Indeed @timtreis it works if I replace
Polygon(ext, [interior])byMultiPolygon([Polygon(ext, [interior])])But I guess the case of a single
Polygonwith a hole should also work, right? When I have a single polygon with a hole, I prefer not to wrap it into a multi-polygon of 1 polygon!Hm, I guess so far we've been assuming that Polygons don't have holes. Checking the Shapely doc it seems to explicitly allow that. Yeah, we might have to change our logic there.
Reacted by Quentin Blampey, Arne Defauw and Frank Vernaillen- linked a pull request that will close this issuePolygons with holes are now rendered correctly #513
on Nov 17, 2025


As pointed out in #259, the MultiPolygons are partially broken. See image from test:
Should be like shown on the left but is currently as shown on the right
