Last active
July 29, 2023 18:28
-
-
Save jonspring/99ace164ac40bb523675c55846b0d43c to your computer and use it in GitHub Desktop.
XKCD: Bad Map Projection: ABS(Longitude)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# recreation of https://xkcd.com/2807/ | |
library(ggplot2) | |
library(sf) | |
library("rnaturalearth") | |
library("rnaturalearthdata") | |
# library(lwgeom) | |
world <- ne_countries(scale = "small", returnclass = "sf") |> | |
sf::st_as_sf() %>% | |
sf::st_set_crs(value = 4326) | |
ggplot(data = world) + | |
geom_sf() | |
# # https://wilkelab.org/practicalgg/articles/Winkel_tripel.html | |
# crs_wintri <- "+proj=wintri +datum=WGS84 +no_defs +over" | |
# world_wintri <- st_transform_proj(world, crs = crs_wintri) | |
# # https://www.happykhan.com/posts/map-projections-in-r/ | |
# grat_wintri <- | |
# st_graticule(lat = c(-89.9, seq(-80, 80, 20), 89.9)) %>% | |
# st_transform_proj(crs = crs_wintri) | |
# ggplot(data = world) + | |
# geom_sf() + | |
# coord_sf(crs= "+proj=robin") | |
world_rev <- st_geometry(world) * matrix(c(-1,0,0,1), 2, 2) | |
world2 <- world |> | |
st_set_geometry(world_rev) |> | |
sf::st_as_sf() |> | |
sf::st_set_crs(value = 4326) | |
ggplot() + | |
geom_sf(data = world) + | |
geom_sf(data = world2) + | |
coord_sf(xlim = c(0, 180)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment