Propensity to Cycle Tool Advanced Workshop

Introduction

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).

Prior reading

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:

Prerequisites

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")
pkgs = c(
  "cyclestreets",
  "mapview",
  "pct",
  "sf",
  "stats19",
  "stplanr",
  "tidyverse",
  "devtools"
)
remotes::install_cran(pkgs)
# 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") 

Agenda

Part 1: how the Propensity to Cycle Tool works + demo: ‘I do’

Part 2: Co-coding session: getting started with transport data in R: ‘we do’

Part 3: using PCT data for local transport planning: ‘you do’

Exercises

How the PCT works and what you can use it for

The PCT provides data at 4 geographic levels:

Which types of data are most appropriate to tackle each of the questions/problems you identified?

Getting PCT data

In this section we will get PCT data at the MSOA level and plot the result in a simple map.

library(pct)
library(sf)      # key package for working with spatial vector data
library(dplyr)   # in the tidyverse
library(tmap)    # installed alongside mapview
region_name = "isle-of-wight"
zones_all = get_pct_zones(region_name, geography = "msoa")
lines_all = get_pct_lines(region_name, geography = "msoa")
routes_all = get_pct_routes_fast(region_name, geography = "msoa")
rnet_all = get_pct_rnet(region_name)
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)

Visualising PCT data

At its heart, the PCT is a data visualisation tool.

tm_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.

# 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.