-
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
issues with st_crop on s2_data_countries() #239
Comments
I'm pretty sure what's happening is that the box is getting interpreted to have a geodesic edge. This is almost certainly not what anybody doing |
Yes, something along these lines should work: library(sf)
#> Linking to GEOS 3.10.2, GDAL 3.4.3, PROJ 8.2.0; sf_use_s2() is TRUE
library(s2)
co <- st_as_sf(s2_data_countries())
pol <- st_sfc(st_polygon(list(cbind(c(-120, -120, 30, 30, -120),
c(30, 55, 55, 30, 30)))))
pol1 <- st_segmentize(pol, 1)
plot(co)
plot(pol, add=TRUE, border ="blue")
st_crs(pol1) = st_crs(co)
co |>
st_intersection(pol1) |>
plot(border="red", lwd=2, add=TRUE) |
(It works because |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When using
st_crop()
onst_as_sf(s2_data_countries())
, I get some strange results. I faced the same problem withrnaturalearth
(see issue ropensci/rnaturalearth#78), and assumed the problem was thatrnaturalearth
contained invalid geometries (whichs2::s2_data_countries
doesn't seem to contain), but it seems even with valid geometries, there is an issue?Note I am posting here and might need to post instead on
sf
?Thanks!
Created on 2023-05-25 with reprex v2.0.2
The text was updated successfully, but these errors were encountered: