Last active
January 25, 2019 21:56
-
-
Save sschmutz/bf0ad51ce2c810e323cbed4348fe8c84 to your computer and use it in GitHub Desktop.
get data and plot map of Switzerland on a canton level
This file contains 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
# load packages ----------------------------------------------------------- | |
library(here) | |
library(sf) | |
library(ggplot2) | |
# download and read map data ---------------------------------------------- | |
url_gadm <- "https://biogeo.ucdavis.edu/data/gadm3.6/shp/gadm36_CHE_shp.zip" | |
download.file(url = url_gadm, | |
destfile = here("gadm36_CHE_shp.zip")) | |
unzip(zipfile = here("gadm36_CHE_shp.zip"), | |
exdir = here("gadm36_CHE_shp")) | |
gadm36_CHE_1 <- read_sf(dsn = here("gadm36_CHE_shp", "gadm36_CHE_1.shp")) | |
# explore the dataset ----------------------------------------------------- | |
head(gadm36_CHE_1) | |
# plot the map ------------------------------------------------------------ | |
map_switzerland <- | |
gadm36_CHE_1 %>% | |
ggplot() + | |
geom_sf() + | |
coord_sf(datum = NA) + | |
theme_void() | |
ggsave(filename = here("map_switzerland.png"), plot = map_switzerland) |
Author
sschmutz
commented
Jan 25, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment