-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
invalid polygon #222
Comments
Interestingly, library(s2)
x = s2_geog_from_text("POLYGON ((0 0, 3 0, 3 2, 1 1, 2 1, 0 2, 0 0))", check = FALSE)
o = s2_options(split_crossing_edges = TRUE, snap = s2_snap_precision(0))
s2_rebuild(x, o) |> s2_is_valid()
# [1] TRUE
# Warning messages:
# 1: In cpp_s2_rebuild(as_s2_geography(x), options) :
# NAs introduced by coercion to integer range
# 2: In cpp_s2_rebuild(as_s2_geography(x), options) :
# NAs introduced by coercion to integer range but the warnings here seem to indicate that something went wrong, as library(sf)
# Linking to GEOS 3.11.1, GDAL 3.6.2, PROJ 9.1.1; sf_use_s2() is TRUE
s2_rebuild(x, o) |> st_as_sfc() -> y
# Warning messages:
# 1: In cpp_s2_rebuild(as_s2_geography(x), options) :
# NAs introduced by coercion to integer range
# 2: In cpp_s2_rebuild(as_s2_geography(x), options) :
# NAs introduced by coercion to integer range
y[[1]]
# POLYGON ((0 0, 3 0, 3 2, 2 1, 1 1, 0 2, 0 0)) |
First, the warning is coming from Maybe a unary union is needed to fix this one? library(s2)
x = s2_geog_from_text("POLYGON ((0 0, 3 0, 3 2, 1 1, 2 1, 0 2, 0 0))", check = FALSE)
o = s2_options(split_crossing_edges = TRUE)
x |>
s2_is_valid()
#> [1] FALSE
x |>
s2_rebuild(o) |>
s2_is_valid()
#> [1] FALSE
x |>
s2_rebuild(o) |>
s2_union() |>
s2_is_valid()
#> [1] TRUE Created on 2023-03-30 with reprex v2.0.2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I was hoping that this polygon:
would be made valid by:
Zooming in, the resulting geometry
seems valid (inner ring CW, touches outer ring in a point), and
is considered valid by GEOS. Does s2geometry have a different concept of valid, or does the package handle this?
The text was updated successfully, but these errors were encountered: