Skip to content
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 geometry world: Loop 0 is not valid #99

Closed
JJFoest opened this issue Dec 5, 2023 · 3 comments
Closed

Invalid geometry world: Loop 0 is not valid #99

JJFoest opened this issue Dec 5, 2023 · 3 comments

Comments

@JJFoest
Copy link

JJFoest commented Dec 5, 2023

Dear rnaturalearth developers,

Firstly, thank you for making an awesome package (I'm using v. 0.3.4).
I've been running into some problems with invalid geometry.

If I run:

worldshape <- rnaturalearth::ne_countries(returnclass = "sf") %>%
sf::st_union()

I receive the error message:
"Error in wk_handle.wk_wkb(wkb, s2_geography_writer(oriented = oriented, :
Loop 0 is not valid: Edge 0 crosses edge 78".

Now, if I try to force the geometry to be valid:

worldshape <- rnaturalearth::ne_countries(returnclass = "sf") %>%
sf::st_make_valid() %>%
sf::st_union()

I receive the same error message.

If it helps, I am running v. 1.0-13 of sf in R 4.3.1.

Thank you for your consideration.

@Nowosad
Copy link

Nowosad commented Dec 5, 2023

@JJFoest see r-spatial/sf#1649 (comment)

@PMassicotte
Copy link
Contributor

If you turn s2 off, does it help?

@JJFoest
Copy link
Author

JJFoest commented Dec 5, 2023

Hi! Thanks for the suggestions.

This runs ok:

sf_use_s2(FALSE)
worldshape <- rnaturalearth::ne_countries(returnclass = "sf") %>%
sf::st_union()
worldshape

I only get a message: "although coordinates are longitude/latitude, st_union assumes that they are planar".

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants