library(arc2r)
library(sf)
library(tmap)
# Point dataset depicting the train stations locations across Switzerland
data("haltestelle_bahn")

# Dataset depicting Switzerland on canton level
data("kantonsgebiet")

kanton_filter <- filter(kantonsgebiet, NAME %in% c("Zürich","St. Gallen","Thurgau","Aargau"))

plot(st_geometry(haltestelle_bahn))
plot(st_geometry(kanton_filter), col = "grey", add = TRUE,alpha = 1)
haltestelle_bahn_clipped <- st_intersection(kanton_filter, haltestelle_bahn)
plot(st_geometry(haltestelle_bahn_clipped))
plot(st_geometry(kanton_filter), add = TRUE,alpha = 1)
haltestellen_split <- split(haltestelle_bahn_clipped,haltestelle_bahn_clipped$name)

str(haltestellen_split[1:2])


arc2r/book documentation built on March 5, 2021, 2:10 p.m.