Skip to content

s2_rebuild transforms POLYGON FULL into an empty geometrycollection #262

Open

Description

@edzer

I'm (finally) implementing support for POLYGON FULL in sf, and ran into s2_rebuild converting an s2 full polygon to a GEOMETRYCOLLECTION EMPTY. I don't think it should! I'll work around it in sf, but it would be nice if it wasn't touched in s2_rebuild: In a debug session in sf::st_make_valid():

Browse[1]> s2
<geodesic s2_geography[2] with CRS=OGC:CRS84>
[1] POLYGON ((0 -90, 0 -90))             POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0...
Browse[1]> 
debug: s2 = s2::s2_rebuild(s2, s2_options)
Browse[1]> 
debug: st_as_sfc(s2, crs = crs)
Browse[1]> s2
<geodesic s2_geography[2] with CRS=OGC:CRS84>
[1] GEOMETRYCOLLECTION EMPTY             POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0...

Activity

  1. paleolimbot commented on Sep 20, 2024

    @paleolimbot
    Collaborator

    That's a great point...the S2Builder doesn't know about full polygons (I seem to remember) and there are some special gymnastics to ensure that it is handled properly in boolean operations. A single full polygon can probably be special-cased...I am not sure what would happen if one tried to rebuild a polygon that contained a FULL loop, though.

  2. paleolimbot commented on Sep 20, 2024

    @paleolimbot
    Collaborator

    I don't think we have an s2_is_full() to special-case this at the R level but that would basically be the workaround.

  3. edzer commented on Sep 21, 2024

    @edzer
    MemberAuthor

    s2_is_full() would be great to have!

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions