Skip to content

Instantly share code, notes, and snippets.

View edonnachie's full-sized avatar

Ewan Donnachie edonnachie

View GitHub Profile
@edonnachie
edonnachie / sf_map_overlay.R
Last active May 9, 2022 21:57
Demonstration of how to overlay one region onto another using R and sf
library(sf)
library(ggplot2)
# Data from https://www.geoboundaries.org/index.html#getdata
de2 <- read_sf("data/geoBoundaries-DEU-ADM2-all/geoBoundaries-DEU-ADM2_simplified.shp")
# Extract Munich and Berlin to separate objects
munich <- dplyr::filter(de2, DistrictCo == "09162")
berlin <- dplyr::filter(de2, DistrictCo == "11000")