This vignette supports workshops on advanced usage and development of the Propensity to Cycle Tool (PCT). Beginner and intermediate PCT events focus on using the PCT via the web application hosted at www.pct.bike and the data provided by the PCT in QGIS.
The focus here is on analysing cycling potential in the open source statistical programming language R, in which the majority of the PCT was built. It will show how the code underlying the PCT works, how the underlying data can be accessed for reproducible analysis, and how the methods can be used to generate new scenarios of cycling uptake.
If you are an intermediate user, it may be worth brushing-up on your R skills, e.g. by taking a free online course such as that provided by DataCamp or by working through Chapter 2 onwards of the open source book Geocomputation with R (see reading list below for more transport-specific resources).
In addition to computer hardware (a laptop) and software (an up-to-date R set-up and experience using R) pre-requisites, you should have read, or at least have working knowledge of the contents of, the following publications, all of which are freely available online:
To ensure your computer is ready for the course, you should be able to run the following lines of R code on your computer:
install.packages("remotes")
= c(
pkgs "cyclestreets",
"mapview",
"pct",
"sf",
"stats19",
"stplanr",
"tidyverse",
"devtools"
)::install_cran(pkgs)
remotes# remotes::install_github("ITSLeeds/pct")
To test your computer is ready to work with PCT data in R, try running the following command:
source("https://github.com/ITSLeeds/pct/raw/master/inst/test-setup.R")
Part 1: how the Propensity to Cycle Tool works + demo: ‘I do’
test-setup.R
(14:15 - 14:30)Part 2: Co-coding session: getting started with transport data in R: ‘we do’
Working through the code in pct_training.R
(15:00 - 15:30)
Live demo: overlaying PCT data with data from the Rapid tool and OSM (15:30 - 15:45)
☕☕☕ 15 minute break ☕☕☕
Part 3: using PCT data for local transport planning: ‘you do’
Getting set-up with RStudio and input data (16:00 - 16:15, Robin)
Break-out rooms (16:15 - 17:00)
get_pct_rnet
)Presentation of work and next steps (17:00 - 17:15)
Networking and ‘ideas with beers’ 🍻🍻🍻 (17:20 - 18:00)
These links may be useful when working through the exercises below:
The PCT provides data at 4 geographic levels:
Which types of data are most appropriate to tackle each of the questions/problems you identified?
In this section we will get PCT data at the MSOA level and plot the result in a simple map.
library(pct)
library(dplyr) # in the tidyverse
library(tmap) # installed alongside mapview
= "isle-of-wight"
region_name = get_pct_zones(region_name, geography = "msoa")
zones_all = get_pct_lines(region_name, geography = "msoa")
lines_all = get_pct_routes_fast(region_name, geography = "msoa")
routes_all = get_pct_rnet(region_name) rnet_all
plot(zones_all$geometry)
plot(lines_all$geometry, col = "blue", add = TRUE)
plot(routes_all$geometry, col = "green", add = TRUE)
plot(rnet_all$geometry, col = "red", lwd = rnet_all$bicycle / 10, add = TRUE)
At its heart, the PCT is a data visualisation tool.
tmap
packagetm_shape(rnet_all) +
tm_lines(lwd = "dutch_slc", scale = 9)
#> Legend labels were too wide. Therefore, legend.text.size has been set to 0.47. Increase legend.width (argument of tm_layout) to make the legend wider and therefore the labels larger.
tmap
package# interactive plot
tmap_mode("view")
#> tmap mode set to interactive viewing
tm_shape(rnet_all) +
tm_lines(lwd = "dutch_slc", scale = 9)
#> Legend for line widths not available in view mode.