tilemap_ch: Tilemap Switzerland

View source: R/tilemap_Switzerland.R

tilemap_chR Documentation

Tilemap Switzerland

Description

A data.frame (or spatial object) of Switzerland's tilemap

Usage

tilemap_ch(fortified = T, withLake = F)

Arguments

fortified,

a logical a data.frame instead of spatial object to be returned

withLake,

a logical have Leman and Bodensee lakes?

Value

a data.frame of class simple feature

Source

https://github.com/ernstbaslerpartner/Switzerland_Tilemap

Examples

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)

d-qn/tamMap documentation built on Oct. 20, 2023, 7:41 a.m.