View source: R/tilemap_Switzerland.R
tilemap_ch | R Documentation |
A data.frame (or spatial object) of Switzerland's tilemap
tilemap_ch(fortified = T, withLake = F)
fortified |
a logical a data.frame instead of spatial object to be returned |
withLake |
a logical have Leman and Bodensee lakes? |
a data.frame of class simple feature
https://github.com/ernstbaslerpartner/Switzerland_Tilemap
tmap_ch <- tilemap_ch()
## Not run:
require(sf)
require(tidyverse)
# cantonal label, as centroid of the tiles. Needs to be a simple (non-sf) object to be plotted as geom_text
tmap.label <- data.frame(label = as.character(tmap_ch$Name), tmap_ch %>% st_centroid() %>% st_coordinates())
# PLOT
tm_ch <- ggplot() +
geom_sf(data = tmap_ch) +
theme_map()
# add canton 2 letters labels
tm_ch + geom_text(data = tmap.label, aes(x = X, y = Y, label = label), hjust = 0.5, vjust = 0.5)
## Plot ballot map, Loi fédérale sur la radio et la télévision 5950
fballot_canton <- loadCantonsCHFederalBallot()
vote <- fballot_canton[,which(colnames(fballot_canton) == "5950")] %>% enframe()
tmap_ch <- left_join(tmap_ch, vote, by = c("Name" = "name"))
ggplot() +
geom_sf(data = tmap_ch, aes(fill = value)) +
theme_map() +
# add canton 2 letters labels
geom_text(data = tmap.label, aes(x = X, y = Y, label = label), hjust = 0.5, vjust = 0.5, colour = "white", size = 2.5)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.