Skip to content

Instantly share code, notes, and snippets.

@sschmutz sschmutz/map_switzerland.R
Last active Jan 25, 2019

Embed
What would you like to do?
get data and plot map of Switzerland on a canton level
# 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)
@sschmutz

This comment has been minimized.

Copy link
Owner Author

sschmutz commented Jan 25, 2019

map_switzerland

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.