class: center, middle, inverse, title-slide # The Propensity to Cycle Tool ## π²
Advanced Training Workshop ### Robin Lovelace and Joey Talbot, ITS, University of Leeds ### Public Health + Sustainable Transport Summit 2020
--- # Intro + agenda This workshop will provide an overview of the PCT for advanced users, including: - transport planners with experience of evidence-based prioritisation - researchers with experience of using origin-destination, route and route network level data - programmers, developers and others wanting to extend PCT methods for the public benefit -- The workshop will be broken into three main parts: Part 1: how the Propensity to Cycle Tool works + demo: 'I do' (14:00 - 15:00) Part 2: Co-coding session: 'we do' (15:00 - 15:45) βββ 15 minute break βββ Part 3: using PCT data for your needs: 'you do' (16:00 - 17:00) - Presentation of work and next steps (17:00 - 17:15) - Networking and 'ideas with beers' π»π»π» (17:20 - 18:00) --- # Description: In this workshop you will take a deep dive into 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 but the focus here is on analysing cycling potential in the open source statistical programming language R. The majority of the PCT was built on R, which is a powerful object-orientated programming language with a focus on statistical modelling, visualisation and geographic analysis. The workshop 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. --- # Preparation If you are inexperienced with R you should prepare by - Essential: taking an online course such as the free[ 'Introduction to R' course provided by DataCamp ](https://www.datacamp.com/courses/free-introduction-to-r) - Essential: ensuring you have [installed](https://rstudio-education.github.io/hopr/starting.html) up-to-date versions of R (R 4.0.0 or greater), RStudio (1.2 or greater) and the pct R package (0.6.0) on your computer - Essential: test your computer set up by running the R code here [github.com/ITSLeeds/pct/blob/master/inst/test-setup.R](https://github.com/ITSLeeds/pct/blob/master/inst/test-setup.R) - you should make a note of the result of this final commented-out command: `round(mean(rnet_potential$Potential))` - Highly recommended: working through and reproducing results in Chapter 12 onwards of the open source book Geocomputation with R (see [geocompr.robinlovelace.net/transport.html](https://geocompr.robinlovelace.net/transport.html)) If you are new to R but have *not* completed the above tasks you may be unable to follow the second and third sections of the workshop outlined in the agenda below. --- # Prerequisites See [here](https://docs.ropensci.org/stats19/articles/stats19-training-setup.html) for a guide on installing R and RStudio for transport data research. To get the access code for the tutorial, you will need to first work through the code shown here: https://github.com/ITSLeeds/pct/blob/master/inst/test-setup.R After you have run the code, running the following line should give you a number that will give you the access code for the course: ```r round(mean(rnet_potential$Potential)) ``` Save that 3 digit number, it will allow access to the workshop. If you have any issues with your computer set-up, please ask a question here (you will need to sign-up for a GitHub account if you have not already done so): https://github.com/ITSLeeds/pct/issues/67 --- background-image: url(https://media.giphy.com/media/YlQQYUIEAZ76o/giphy.gif) background-size: cover class: center, middle # How the PCT works --- ## The first prototype of the PCT - 1st prototype: Hackathon at ODI Leeds in February 2015 - We identifying key routes and mapped them - For description of aims, see Lovelace et al. (2017) <!-- --> --- <!-- ## Launched in 2017 --> - Launched in 2017 with the Cycling and Walking Investment Strategy ([CWIS](https://www.gov.uk/government/publications/cycling-and-walking-investment-strategy))  Photo: demo of the PCT to Secretary of State for Transport ([March 2017](https://environment.leeds.ac.uk/transport/news/article/187/research-showcased-to-secretary-of-state)) --- ## The PCT in 2020 - Now the go-to tool for strategic cycle network planning in England and Wales, used by most local authorities with cycling plans ([source](https://npct.github.io/pct-shiny/regions_www/www/static/03d_other_reports/2019-use-of-pct-report.pdf)). .pull-left[ ## Geographic levels in the PCT - Generate and analyse route networks for transport planning with reference to: - Zones - Origin-destination (OD) data - Geographic desire lines - Route allocation using different routing services - Route network generation and analysis ] .pull-right[  See these levels at [www.pct.bike](https://www.pct.bike) ] --- ## Let's look at zones  --- ## MSOA vs LSOA zones (MSOA zones ~5 times bigger) <img src="https://user-images.githubusercontent.com/1825120/96583573-d3c1eb00-12d4-11eb-88b8-ca78087b63f7.png" width="50%" /><img src="https://user-images.githubusercontent.com/1825120/96583629-eb00d880-12d4-11eb-9211-d015e2991267.png" width="50%" /> - MSOA areas have a population of 5-15k - LSOAs have a population of 1-3k - Route network data in PCT data based on LSOA data - MSOAs can be useful for identifying key desire lines - See [ons.gov.uk](https://www.ons.gov.uk/methodology/geography/ukgeographies/censusgeography) for details --- ## OD data Table: Origin-destination data. Open MSOA-MSOA commute data from the 2011 census, accessed using the R package pct. |geo_code1 |geo_code2 | all| train| bus| taxi| car_driver| car_passenger| bicycle| foot| id| perc_cycle| |:---------|:---------|----:|-----:|---:|----:|----------:|-------------:|-------:|----:|--:|----------:| |E02002363 |E02006875 | 922| 5| 356| 7| 375| 76| 43| 53| 1| 4.7| |E02002373 |E02006875 | 1037| 111| 424| 20| 155| 30| 73| 214| 2| 7.0| |E02002385 |E02006875 | 958| 121| 334| 19| 118| 25| 52| 283| 3| 5.4| |E02006852 |E02002392 | 437| 1| 96| 3| 142| 26| 61| 108| 4| 14.0| |E02006852 |E02006875 | 1221| 14| 509| 13| 401| 50| 99| 118| 5| 8.1| |E02006861 |E02006875 | 1177| 43| 400| 30| 123| 28| 56| 492| 6| 4.8| --- ## Desire lines <!-- --> --- ## Routes  --- ### Route networks ```r rnet = stplanr::overline(r, "bicycle") plot(rnet, lwd = rnet$bicycle / 10) ``` <!-- --> --- ### Cycling uptake  -- Dose/response modelling: about cycling in response to distance, hilliness and other factors. Source: [pct R package website](https://itsleeds.github.io/pct/reference/uptake_pct_govtarget.html) --- background-image: url(https://user-images.githubusercontent.com/1825120/96583573-d3c1eb00-12d4-11eb-88b8-ca78087b63f7.png) # Live demo of the PCT for Bristol ## See https://www.pct.bike/ --- .pull-left[ # Uses of the PCT - Visioning - Planning strategic cycle networks - Identifying corridors with high latent demand Uses that were not initially planned - Pop-up cycleway planning - LTN planning? ] -- .pull-right[ ## What it cannot do - Junction design - *Exact* route plan (PCT results are based on 'fastest route') - Public-transport integration - Other trip purposes beyond single stage journeys cycling to work and school - Planning for future developments ] -- #### For further info, see the training materials at [itsleeds.github.io](https://itsleeds.github.io/pct/articles/pct_training.html) #### Many use cases on the PCT website: [pct.bike/manual.html](https://www.pct.bike/manual.html) - Case studies of over a dozen areas, including Greater Manchester and Herefordshire in the manual --- ## Estimating health benefits of cycling uptake with the PCT - The PCT uses a modified version of the HEAT methodology to calculate health benefits of scenarios of change - Based on the DfT's TAG methodology - The scenarios are **what if** scenarios not forecasts - See the PCT manual for further information: [pct.bike/manual.html](https://npct.github.io/pct-shiny/regions_www/www/static/03a_manual/pct-bike-eng-user-manual-c1.pdf) - See the DfT's [AMAT tool](https://assets.publishing.service.gov.uk/government/uploads/system/uploads/attachment_data/file/888754/amat-user-guidance.pdf) also  --- ## From evidence to network plans Plans from Leeds City Council responding to national [guidance](https://www.gov.uk/government/publications/reallocating-road-space-in-response-to-covid-19-statutory-guidance-for-local-authorities) and [funding](https://www.gov.uk/government/news/2-billion-package-to-create-new-era-for-cycling-and-walking) for 'pop-up' cycleways (image credit: [Leeds City Council](https://news.leeds.gov.uk/news/leeds-city-council-announces-emergency-walking-and-cycling-plans-in-response-to-covid-19)):  --- background-image: url(https://raw.githubusercontent.com/cyipt/popupCycleways/master/figures/results-top-leeds.png) ## The Rapid tool - see [cyipt.bike/rapid](https://www.cyipt.bike/rapid/) - Live demo by Joey Talbot --- # The PCT Advanced Workshop ## 12th November, 2pm, online  --- ## The team ### Robin Lovelace - Geographer by Training - Associate Professor in Transport Data Science, Institute for Transport Studies, University of Leeds - Lead Developer of the Propensity to Cycle Tool - R developer and teacher, author of open source books *Efficient R Programming* and *Gecomputation with R* -- ### Joey Talbot - Experienced data scientist - Policy and planning knowledge through role in Transport for New Homes ### Rosa FΓ©lix - Transport Engineer by training - Working on cycling potential and infrastructure prioritisation --- ### How about you? .pull-left[  ] -- .pull-right[  ] --- ## Overview of workshop <!-- - The venue + facilities --> Part 1: how the Propensity to Cycle Tool works + demo: 'I do' - Introductions (14:00 - 14:15) - Walk through of [`test-setup.R`](https://github.com/ITSLeeds/pct/blob/master/inst/test-setup.R) (14:15 - 14:40) - Demonstration of cycling potential in a new context (14:40 - 14:45) - Questions, break and debugging the test code in breakout rooms (14:45 - 15:00) - Room 1: technical questions and debugging code (Joey) - Room 2: methodological questions about the PCT (Robin) - Room 3: applying the PCT in new contexts (Rosa) - Room 4: networking -- Part 2: Co-coding session: getting started with transport data in R: 'we do' - Working through the code in [`pct_training.R`](https://github.com/ITSLeeds/pct/blob/master/inst/pct_training.R) (15:00 - 15:30) - Breakout rooms 2 and 3 open for people who have questions - Live demo: overlaying PCT data with data from the Rapid tool and OSM (15:30 - 15:45) βββ 15 minute break βββ --- ## Workshop overview - Part III 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) - Getting and visualising PCT data (e.g. `get_pct_rnet`) - Running the PCT for new areas - Advanced topics (different routing, uptake and route network summary methods - developments in **stplanr**) - Presentation of work and next steps (17:00 - 17:15) - Networking and 'ideas with beers' π»π»π» (17:20 - 18:00) --- ## Learning outcomes - Understand the data and code underlying the PCT - Download data from the PCT at various geographic levels - Use R as a tool for data analysis to support evidence-based planning -- It's about free and open source software for a sustainable future π  --- background-image: url(https://media.giphy.com/media/YlQQYUIEAZ76o/giphy.gif) # Coding Ideal: ```r od_test$perc_cycle = round(od_test$bicycle / od_test$all) * 100 l = od_to_sf(od_test, od_data_centroids) r = stplanr::route(l = l, route_fun = journey) rnet = overline(r, "bicycle") ``` --  Reality --- ## Key stages of PCT approach - Reproducible, open, scripted, enabling modifications, e.g.: - Find short routes in which more people drive than cycle -- - Stage 1: get data ```r # Set-up, after installing pct and checking out www.pct.bike: library(dplyr) library(sf) desire_lines_all = pct::get_pct_lines(region = "isle-of-wight") %>% top_n(n = 1000, wt = all) ``` --- ## Stage II: Subset data of interest - Interested only in major lines ```r library(sf) desire_lines = desire_lines_all %>% filter(all > 50) %>% select(geo_code1, geo_code2, all, bicycle, foot, car_driver, rf_dist_km) plot(desire_lines) ``` <!-- --> --- ## Stage III: Visualisation <!-- A fundamental part of data science is being able to understand your data. --> <!-- That requires visualisation, R is great for that: --> <!-- - Interactively: --> ```r library(tmap) tmap_mode("view") tm_shape(desire_lines) + tm_lines("all", scale = 9) + tm_basemap(server = leaflet::providers$OpenStreetMap) ```
--- ## Stage IV: Origin-destination data analysis - Now we have data in our computer, and verified it works, we can use it - Which places are most car dependent? ```r car_dependent_routes = desire_lines %>% mutate(percent_drive = car_driver / all * 100) %>% filter(rf_dist_km < 3 & rf_dist_km > 1) ``` - Get routes ```r routes = stplanr::line2route(car_dependent_routes) car_dependent_routes$geometry = routes$geometry ``` <!-- -- --> <!-- - Any questions? --> <!-- -- --> <!-- - Everyone happy with RStudio? --> <!-- --- --> <!-- # Supporting reference materials --> <!-- All interactive programming/analysis with command line interface involves frequent reference to documentation, and data science is no exception. Places to look for help (in roughly descending order): --> <!-- -- --> <!-- - Your colleague --> <!-- - R's internal help (e.g. with `?functonname` or `vignettes(package = "packagename)`) --> <!-- - Online documentation, e.g. for the pct package: https://itsleeds.github.io/pct/ --> <!-- - *Transport and Geographic Data Science with R*: An introduction to R aimed at transport planners: https://git.io/tds2dayex --> <!-- - The transport chapter ([12](https://geocompr.robinlovelace.net/transport.html)) in the open source book [*Geocomputation with R*](https://geocompr.robinlovelace.net/) --> <!-- - R for Data Science --> <!-- --- --> <!-- # Exercises --> <!-- - If you're happy with R, work through G1 to G8 in the [exercises](https://itsleeds.github.io/pct/articles/pct_training.html#exercises), starting: --> <!-- - G1: Using the PCT's online interface, hosted at [www.pct.bike/m/?r=isle-of-wight](https://www.pct.bike/m/?r=isle-of-wight), identify the MSOA **zone** that has the highest number of people who cycle to work. --> <!-- - If you're just getting started with RStudio: Work through Section 1 of https://git.io/tds2dayex --> <!-- - Getting up to speed with data manipulation in the tidyverse: Work through and reproduce the code in Section [5.2](https://r4ds.had.co.nz/transform.html#filter-rows-with-filter) of R for Data Science. --> <!-- --- --> <!-- # The PCT hackathon --> <!-- -- --> <!-- Overall aim: generate ideas related to and extending the PCT --> <!-- -- --> <!-- Ideas: --> <!-- - Create a route network reflecting where you would invest if the priority was reducing car trips of less than 5 km --> <!-- -- --> <!-- - Design interventions to replace short car trips across West Yorkshire (or another region of your choice) using the PCT methods/data to support your decisions --> <!-- -- --> <!-- - Identify quiet routes and design a quiet route network for city/region of your choice, e.g. Leeds --> <!-- -- --> <!-- - Import alternative origin-destination datasets and use those as the basis for propensity to cycle analysis for trip purposes other than single stage commutes, encapsulated in the commut layer in the PCT --> <!-- - Any other layers/scenarios/hacks: welcome! Comments in this repo's [issue tracker](https://github.com/ITSLeeds/pct/issues) also welcome. --> --- # Other topics --- ## Transport software - which do you use? <table> <caption>Sample of transport modelling software in use by practitioners. Note: citation counts based on searches for company/developer name, the product name and 'transport'. Data source: Google Scholar searches, October 2018.</caption> <thead> <tr> <th style="text-align:left;"> Software </th> <th style="text-align:left;"> Company/Developer </th> <th style="text-align:left;"> Company HQ </th> <th style="text-align:left;"> Licence </th> <th style="text-align:right;"> Citations </th> </tr> </thead> <tbody> <tr> <td style="text-align:left;"> Visum </td> <td style="text-align:left;"> PTV </td> <td style="text-align:left;"> Germany </td> <td style="text-align:left;"> Proprietary </td> <td style="text-align:right;"> 1810 </td> </tr> <tr> <td style="text-align:left;"> MATSim </td> <td style="text-align:left;"> TU Berlin </td> <td style="text-align:left;"> Germany </td> <td style="text-align:left;"> Open source (GPL) </td> <td style="text-align:right;"> 1470 </td> </tr> <tr> <td style="text-align:left;"> TransCAD </td> <td style="text-align:left;"> Caliper </td> <td style="text-align:left;"> USA </td> <td style="text-align:left;"> Proprietary </td> <td style="text-align:right;"> 1360 </td> </tr> <tr> <td style="text-align:left;"> SUMO </td> <td style="text-align:left;"> DLR </td> <td style="text-align:left;"> Germany </td> <td style="text-align:left;"> Open source (EPL) </td> <td style="text-align:right;"> 1310 </td> </tr> <tr> <td style="text-align:left;"> Emme </td> <td style="text-align:left;"> INRO </td> <td style="text-align:left;"> Canada </td> <td style="text-align:left;"> Proprietary </td> <td style="text-align:right;"> 780 </td> </tr> <tr> <td style="text-align:left;"> Cube </td> <td style="text-align:left;"> Citilabs </td> <td style="text-align:left;"> USA </td> <td style="text-align:left;"> Proprietary </td> <td style="text-align:right;"> 400 </td> </tr> <tr> <td style="text-align:left;"> sDNA </td> <td style="text-align:left;"> Cardiff University </td> <td style="text-align:left;"> UK </td> <td style="text-align:left;"> Open source (GPL) </td> <td style="text-align:right;"> 170 </td> </tr> </tbody> </table> --- ## Data science and the tidyverse - Inspired by Introduction to data science with R (available free [online](https://r4ds.had.co.nz/)) (Grolemund and Wickham, 2016) <img src="https://d33wubrfki0l68.cloudfront.net/b88ef926a004b0fce72b2526b0b5c4413666a4cb/24a30/cover.png" width="30%" /> --- ## A geographic perspective - See https://github.com/ITSLeeds/TDS/blob/master/catalogue.md - Paper on the **stplanr** paper for transport planning (available [online](https://cran.r-project.org/web/packages/stplanr/vignettes/stplanr-paper.html)) (Lovelace and Ellison, 2018) - Introductory and advanced content on geographic data in R, especially the [transport chapter](https://geocompr.robinlovelace.net/transport.html) (available free [online](https://geocompr.robinlovelace.net/)) (Lovelace, Nowosad, and Muenchow, 2019) - Paper on analysing OSM data in Python (available [online](https://arxiv.org/pdf/1611.01890)) --- # Getting support -- With open source software, the world is your support network! -- - Recent example: https://stackoverflow.com/questions/57235601/ -- - [gis.stackexchange.com](https://gis.stackexchange.com/questions) has 21,314 questions - [r-sig-geo](https://r-sig-geo.2731867.n2.nabble.com/) has 1000s of posts - RStudio's Discourse community has 65,000+ posts already! -- - No transport equivalent (e.g. earthscience.stackexchange.com is in beta) - Potential for a Discourse forum or similar: transport is not (just) GIS --- # References [1] G. Grolemund and H. Wickham. _R for Data Science_. O'Reilly Media, Jul. 2016. ISBN: 978-1-4919-1039-9. [2] R. Lovelace and R. Ellison. "stplanr: A Package for Transport Planning". In: _The R Journal_ 10.2 (2018), pp. 7-23. DOI: 10.32614/RJ-2018-053. <URL: https://doi.org/10.32614/RJ-2018-053> (visited on 11/24/2016). [3] R. Lovelace, J. Nowosad, and J. Muenchow. _Geocomputation with R_. CRC Press, 2019. ISBN: 1-138-30451-4. <URL: http://robinlovelace.net/geocompr> (visited on 10/05/2017). <!-- --- --> <!-- ## Transport planning software --> <!-- Transport modelling software products are a vital component of modern transport planning *and* research. --> <!-- - They generate the evidence base on which strategic investments are made and, furthermore, --> <!-- - provide a powerful mechanism for researching alternative futures. --> <!-- -- --> <!-- It would not be an overstatement to say that software determines the range of futures that are visible to policymakers. This makes status of transport modelling software and how it may evolve in the future important questions. --> <!-- What will transport software look like? What will their capabilities be? And who will control? Answers to each of these questions will affect the future of transport systems. --> <!-- -- --> <!-- - Premise: transport planning/modelling software used in practice ~~will become~~ is becoming increasingly data-driven, modular and open. --> <!-- --- --> <!-- ```{r geocompr-cover, echo=FALSE, out.width="20%"} --> <!-- knitr::include_graphics("https://geocompr.robinlovelace.net/images/cover.png") --> <!-- ``` -->