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

Inaccuracy in country polygons which cross 180th meridian in world dataset #67

Closed
HRodenhizer opened this issue Aug 29, 2023 · 5 comments
Labels

Comments

@HRodenhizer
Copy link

Thanks to some help over on SO, I discovered some slight offsets between portions of MULTIPOLYGONs that cross the 180th meridian in the world dataset.

It looks like this is an issue for Russia, Fiji, and Antarctica.

library(sf)
library(spData)
library(dplyr)
library(ggplot)

meridian_180 <- tibble(lon = c(-180,-180),
                       lat = c(-90, 90)) %>%
  st_as_sf(coords = c("lon","lat"),
           crs = "EPSG:4326") %>%
  summarise(geometry = st_combine(geometry)) %>%
  st_cast("LINESTRING") %>% 
  smoothr::densify(max_distance = 1)


world_180 <- world %>%
  slice(st_intersects(., meridian_180, sparse = FALSE) %>%
          as_vector() %>%
          which())

fiji = world_180$geom[1]
russia = world_180$geom[2]
antarctica = world_180$geom[3]
st_distance(st_cast(fiji, 'POLYGON')[c(1, 3)])

image

st_distance(st_cast(russia, 'POLYGON')[c(1, 6)])

image

antarctica <- antarctica %>%
  st_transform(crs = 'EPSG:3412')

ggplot(antarctica) +
  geom_sf()

image

@Nowosad
Copy link
Owner

Nowosad commented Aug 30, 2023

Hi @HRodenhizer that was done on purpose (to avoid some invalid geometry problems with s2).

@Nowosad
Copy link
Owner

Nowosad commented Aug 30, 2023

(Also, importantly datasets from spData are mostly suitable for teaching, benchmarking and testing; I would not suggest using them for research)

@HRodenhizer
Copy link
Author

Got it - that makes sense. I find that this dataset is extremely useful for low-detail, large extent visualizations, but thanks for the warning!

@Robinlovelace
Copy link
Collaborator

Good to have this know bug/feature documented for anyone else who happens across this.

@Nowosad
Copy link
Owner

Nowosad commented Aug 30, 2023

Context: r-spatial/sf#1649 (comment)

@Nowosad Nowosad closed this as completed Aug 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants