Skip to content

MultiPolygons with holes are broken #333

Description

@timtreis

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
image

Activity

  1. self-assigned this
    on Aug 28, 2024
  2. quentinblampey commented on Jun 5, 2025

    @quentinblampey

    Hi @timtreis,

    With the latest spatialdata-plot version, 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()

    Image

    While the polygon should look like this:

    Image

  3. timtreis commented on Jun 5, 2025

    @timtreis
    MemberAuthor

    No, and our testing should've caught that. I'll investigate. Thanks for reporting!

  4. timtreis commented on Jun 6, 2025

    @timtreis
    MemberAuthor

    Wait, you're initialising this as a Shapely.Polygon. Try again with Shapely.MultiPolygon

  5. quentinblampey commented on Jun 6, 2025

    @quentinblampey

    Indeed @timtreis it works if I replace Polygon(ext, [interior]) by MultiPolygon([Polygon(ext, [interior])])

    But I guess the case of a single Polygon with 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!

  6. timtreis commented on Jun 6, 2025

    @timtreis
    MemberAuthor

    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.

    cc @Sonja-Stockhaus

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions