Skip to content

Instantly share code, notes, and snippets.

@dakvid
Created November 27, 2022 03:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dakvid/1a63fdfd39b7c89092360a4c0d3439cc to your computer and use it in GitHub Desktop.
Save dakvid/1a63fdfd39b7c89092360a4c0d3439cc to your computer and use it in GitHub Desktop.
#30DayMapChallenge 2022 - Day 24 - Fantasy
# Overlay New Zealand on a map of Westeros
library(dplyr)
library(sf)
library(rmapshaper)
library(ggplot2)
# https://www.cartographersguild.com/showthread.php?t=30472
locations <-
st_read("GoTRelease/locations.shp")
some_locations <-
locations |>
filter(name %in%
c("King's Landing", "Riverrun", "Dragonstone", "Storm's End",
"Highgarden", "Sunspear", "The Eyrie", "The Twins", "Winterfell",
"Castle Black", "Lannisport", "Craster's Keep"))
political <-
st_read("GoTRelease/political.shp")
CRS_WESTEROS <- st_crs(political)
wall <-
st_read("GoTRelease/wall.shp")
# https://datafinder.stats.govt.nz
nz <-
st_read("regional-council-2021-clipped-generalised.gpkg") |>
filter(REGC2021_V1_00 != "99") |>
count() |>
ms_simplify(keep = 0.02)
nz_projected <-
nz |>
st_transform(crs = CRS_WESTEROS)
point_shift_1 <-
tibble(lat = 0, long = 15) |>
st_as_sf(coords = c("long", "lat"),
crs = CRS_WESTEROS)
nz_shifted <-
nz_projected - st_centroid(nz_projected)
ggplot() +
geom_sf(data = political, aes(fill = name)) +
geom_sf(data = some_locations) +
geom_sf_text(data = some_locations, aes(geometry = geometry, label = name),
nudge_y = 0.9,
family = "High Alpine") +
geom_sf(data = wall) +
geom_sf(data = nz_shifted + 22,
aes(geometry = geometry), fill = "black", alpha = 0.7) +
theme_void() +
theme(plot.background = element_rect(fill = "white", colour = "white"),
panel.background = element_rect(fill = "white", colour = "white"),
legend.position = "none")
ggsave(filename = "day_24_westeros_nz.png",
width = 800, height = 2000, units = "px",
background = "white")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment