class: center, middle, inverse, title-slide # The Propensity to Cycle Tool ## 🚲
Advanced Training Workshop ### Robin Lovelace and Malcolm Morgan, University of Leeds ### ITS Leeds, 2019-08-02
--- # Agenda - 09:30 - 10:00: Arrival and set-up - 10:00 - 11:00: Data and methods underlying the PCT - 11:00 - 12:30: Getting and analysing PCT data - Comparing PCT results with existing road infrastructure - Getting data from the CyIPT - Identfying 'weak links' - Identify gaps in the network Lunch break - 13:30 - 15:30: Extending the PCT: minihack - Alternative scenarios of cycling uptake - A 'replace short car trips' scenario - New input data - Travel to stations - Other extensions of the PCT Break and presentation of results - 16:00 - 16:30: Policy implementation --- # The PCT Advanced Workshop Team ### Robin Lovelace - Geographer by Training - University Academic Fellow in Transport and Big Data, 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* -- ### Malcolm Morgan - Civil Engineer by training - Moved into transport via the Propensity to Cycle Tool Project - Interest in machine learning and routing - Focus on multi-modal routing and energy use (UKERC) -- ### How about you? --- ## Housekeeping - The venue + facilities - The agenda + further info can be found on the pct package website: https://github.com/ITSLeeds/pct - And the PCT training vignette: [itsleeds.github.io/pct/articles/pct_training.html](https://itsleeds.github.io/pct/articles/pct_training.html)
--- ## Learning outcomes By the end of the course, you will be able to: - Understand the data and code underlying the PCT - Download data from the PCT at various geographic levels - Use R as a tool for transport data analysis and cycle network planning -- - Do new things with the PCT data and methods that will support the global transition away from fossil fuels 🚀 --- # Geographic levels in the PCT - Generate and analyse route networks for transport planning with reference to: - Origin-destination (OD) data - Geographic desire lines - Route allocation using different routing services - Route network generation and analysis --- ## 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. --- ## 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](http://geocompr.robinlovelace.net/transport.html) (available free [online](http://geocompr.robinlovelace.net/)) (Lovelace, Nowosad, and Meunchow, 2019) - Paper on analysing OSM data in Python (available [online](https://arxiv.org/pdf/1611.01890)) <img src="https://geocompr.robinlovelace.net/images/cover.png" width="20%" /> --- background-image: url(https://media.giphy.com/media/YlQQYUIEAZ76o/giphy.gif) background-size: cover class: center, middle # Overview of the PCT --- ## The first prototype of the PCT - Developed at a Hackathon at ODI Leeds in February 2015 - Involved identifying key routes and mapping them - For detailed description, see the first PCT paper (Lovelace et al. 2017) <!-- --> --- ## Key stages of PCT - It's all reproducible, enabling modifications, e.g.: - Find short routes in which more people drive than cycle -- - Stage 1: get data from web ```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 desire_lines = desire_lines_all %>% filter(all > 500) %>% 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](http://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 'mini hack' -- Overall aim: learn how you can extend the PCT analysis in a reproducible way -- 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. --- # References Grolemund, Garrett and Hadley Wickham (2016). _R for Data Science_. bibtex:grolemund\_ r\_2016. O'Reilly Media. ISBN: 978-1-4919-1039-9. Lovelace, Robin and Richard Ellison (2018). "stplanr: A Package for Transport Planning". In: _The R Journal_ 10.2, pp. 7-23. DOI: [10.32614/RJ-2018-053](https://doi.org/10.32614%2FRJ-2018-053). URL: [https://doi.org/10.32614/RJ-2018-053](https://doi.org/10.32614/RJ-2018-053) (visited on Nov. 24, 2016). Lovelace, Robin, Jakub Nowosad, and Jannes Meunchow (2019). _Geocomputation with R_. bibtex:lovelace\_ geocomputation\_2019. CRC Press. ISBN: 1-138-30451-4. URL: [http://robinlovelace.net/geocompr](http://robinlovelace.net/geocompr) (visited on Oct. 05, 2017). --- # 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;"> Proprietary </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](http://r4ds.had.co.nz/)) (Grolemund and Wickham, 2016) <img src="https://d33wubrfki0l68.cloudfront.net/b88ef926a004b0fce72b2526b0b5c4413666a4cb/24a30/cover.png" width="30%" /> --- # 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](http://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