This vignettes demonstrates possibilities when zoning systems from different cities meet. It raises the question: how should different systems be combined geographically?
You need the latest version of the package:
::install_github("zonebuilders/zonebuilder") remotes
For this demo, we need the following libraries:
library(zonebuilder) # for the zoning system
library(sf) # for processing spatial data
library(dplyr) # for processing general data
library(tmap) # for visualizing spatial data
We will apply the zoning system to the main Dutch cities, and analyse commuting patterns between the zones. The data can be read as follows:
= readRDS(url("https://github.com/zonebuilders/zonebuilder/releases/download/0.0.1/NLD_cities.Rds"))
NLD_cities = readRDS(url("https://github.com/zonebuilders/zonebuilder/releases/download/0.0.1/NLD_wijk_od.Rds"))
NLD_wijk_od = readRDS(url("https://github.com/zonebuilders/zonebuilder/releases/download/0.0.1/NLD_wijk_centroids.Rds")) NLD_wijk_centroids
Let’s take a look at the NLD_cities
data:
%>% arrange(desc(population)) NLD_cities
…and plot it on an interactive map:
tmap_mode("view") # enable interactive mode in tmap
qtm(NLD_cities, symbols.size = "population")
The following code chunk generated zones for the Dutch cities:
= do.call(rbind, lapply(1:nrow(NLD_cities), function(i) {
zbs = NLD_cities[i, ]
ci
# Amsterdam 5, Eindhoven-Rotterdam 4, Roermond-Zeeland 2, others 3
= ifelse(ci$population < 60000, 2,
nrings ifelse(ci$population < 220000, 3,
ifelse(ci$population < 800000, 4, 5)))
= zb_zone(x = ci, n_circles = nrings) %>%
zb mutate(name = ci$name,
labelplus = paste(ci$name, label, sep = "_"))
zb }))
tm_basemap("OpenStreetMap") +
tm_shape(zbs) +
tm_polygons(col = "circle_id", id = "labelplus", style = "cat", palette = "YlOrBr", alpha = 0.7) +
tm_scale_bar()