# get citations refs = RefManageR::ReadZotero(group = "418217", .params = list(collection = "JFR868KJ", limit = 100)) refs_df = as.data.frame(refs) # View(refs_df) # citr::insert_citation(bib_file = "vignettes/refs_training.bib") RefManageR::WriteBib(refs, "refs.bib") # citr::tidy_bib_file(rmd_file = "vignettes/pct_training.Rmd", messy_bibliography = "vignettes/refs_training.bib") options(htmltools.dir.version = FALSE) knitr::opts_chunk$set(message = FALSE) library(RefManageR) BibOptions(check.entries = FALSE, bib.style = "authoryear", cite.style = 'alphabetic', style = "markdown", first.inits = FALSE, hyperlink = FALSE, dashed = FALSE) my_bib = refs
library(RefManageR) my_bib = RefManageR::ReadBib("refs.bib")
# publish results online cp -Rv inst/rmd/pct-slides* ~/saferactive/site/static/slides/ cp -Rv inst/rmd/libs ~/saferactive/site/static/slides/ cd ~/saferactive/site git add -A git status git commit -am 'Update slides' git push cd -
This workshop will provide an overview of the PCT for advanced users, including:
--
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)
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.
If you are inexperienced with R you should prepare by
round(mean(rnet_potential$Potential))
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.
See here 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:
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
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)
knitr::include_graphics("https://raw.githubusercontent.com/npct/pct-team/master/figures/early.png")
Photo: demo of the PCT to Secretary of State for Transport (March 2017)
.pull-left[
.pull-right[
See these levels at www.pct.bike
]
qtm(od_data_zones_min)
# not the best example # knitr::include_graphics("https://user-images.githubusercontent.com/1825120/96573136-a1f55800-12c5-11eb-8921-c9938cd9e929.gif") knitr::include_graphics(c( "https://user-images.githubusercontent.com/1825120/96583573-d3c1eb00-12d4-11eb-88b8-ca78087b63f7.png", "https://user-images.githubusercontent.com/1825120/96583629-eb00d880-12d4-11eb-9211-d015e2991267.png" )) # 32844 / 6791
library(tmap) library(od) tmap_mode("plot") od_test = od::od_data_df od_test$id = 1:nrow(od_test) od_test$perc_cycle = round(od_test$bicycle / od_test$all, 3) * 100 knitr::kable(od_test, caption = "Origin-destination data. Open MSOA-MSOA commute data from the 2011 census, accessed using the R package pct.")
l = od_to_sf(od_test, od_data_centroids) l = dplyr::select(l, id, foot, bicycle, car_driver, perc_cycle) p = od_data_centroids p = p[l, ] tm_shape(l) + tm_lines("perc_cycle", palette = "viridis", lwd = "car_driver", legend.lwd.show = FALSE, scale = 9, alpha = 0.5) + tm_text("id") + tm_shape(p) + tm_text("geo_code")
library(cyclestreets) r = stplanr::route(l = l, route_fun = journey) saveRDS(r, "routes_od_data_df_df.Rds") piggyback::pb_upload("routes_od_data_df_df.Rds") piggyback::pb_download_url("routes_od_data_df_df.Rds") file.remove("routes_od_data_df_df.Rds")
tm_shape(r) + tm_lines("perc_cycle", palette = "viridis", lwd = "car_driver", legend.lwd.show = FALSE, scale = 9, alpha = 0.5) + tm_shape(p) + tm_text("geo_code")
u = "https://github.com/ITSLeeds/pct/releases/download/0.5.0/routes_od_data_df_df.Rds" f = basename(u) if(!file.exists(f)){ download.file(u, f) } r = readRDS(f)
rnet = stplanr::overline(r, "bicycle") plot(rnet, lwd = rnet$bicycle / 10)
--
Dose/response modelling: about cycling in response to distance, hilliness and other factors. Source: pct R package website
background-image: url(https://user-images.githubusercontent.com/1825120/96583573-d3c1eb00-12d4-11eb-88b8-ca78087b63f7.png)
.pull-left[
Uses that were not initially planned
]
--
.pull-right[
]
--
Plans from Leeds City Council responding to national guidance and funding for 'pop-up' cycleways (image credit: Leeds City Council):
background-image: url(https://raw.githubusercontent.com/cyipt/popupCycleways/master/figures/results-top-leeds.png)
--
.pull-left[
]
--
.pull-right[
]
Part 1: how the Propensity to Cycle Tool works + demo: 'I do'
test-setup.R
(14:15 - 14:40)--
Part 2: Co-coding session: getting started with transport data in R: 'we do'
pct_training.R
(15:00 - 15:30)☕☕☕ 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
)Advanced topics (different routing, uptake and route network summary methods - developments in stplanr)
Presentation of work and next steps (17:00 - 17:15)
library(leaflet) l = stplanr::geo_code("Institute for Transport Studies, University of Leeds") leaflet() %>% addProviderTiles(provider = providers$OpenStreetMap.BlackAndWhite) %>% addMarkers(lng = l[1], lat = l[2])
--
It's about free and open source software for a sustainable future r emojifont::emoji("rocket")
background-image: url(https://media.giphy.com/media/YlQQYUIEAZ76o/giphy.gif)
Ideal:
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
--
# Aim: get top 1000 lines in repo library(dplyr) library(sf) desire_lines_all = pct::get_pct_lines(region = "isle-of-wight") desire_lines = desire_lines_all %>% top_n(1000, all) write_sf(desire_lines, "desire_lines.geojson") piggyback::pb_upload("desire_lines.geojson")
# 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)
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)
.pull-left[ plot(desire_lines) ] .pull-right[ ]
library(tmap) tmap_mode("view") tm_shape(desire_lines) + tm_lines("all", scale = 9) + tm_basemap(server = leaflet::providers$OpenStreetMap)
Now we have data in our computer, and verified it works, we can use it
Which places are most car dependent?
car_dependent_routes = desire_lines %>% mutate(percent_drive = car_driver / all * 100) %>% filter(rf_dist_km < 3 & rf_dist_km > 1)
routes = stplanr::line2route(car_dependent_routes) car_dependent_routes$geometry = routes$geometry
u = "https://github.com/ITSLeeds/TDS/raw/master/transport-software.csv" tms = readr::read_csv(u)[1:5] tms = dplyr::arrange(tms, dplyr::desc(Citations)) knitr::kable(tms, booktabs = TRUE, 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.", format = "html")
r Citep(my_bib, "grolemund_r_2016", .opts = list(cite.style = "authoryear"))
knitr::include_graphics("https://d33wubrfki0l68.cloudfront.net/b88ef926a004b0fce72b2526b0b5c4413666a4cb/24a30/cover.png")
See https://github.com/ITSLeeds/TDS/blob/master/catalogue.md
Paper on the stplanr paper for transport planning (available online) r Citep(my_bib, "lovelace_stplanr:_2018", .opts = list(cite.style = "authoryear"))
r Citep(my_bib, "lovelace_geocomputation_2019", .opts = list(cite.style = "authoryear"))
r Citep(my_bib, "boeing_osmnx_2017", .opts = list(cite.style = "authoryear"))
(available online) --
With open source software, the world is your support network!
--
--
gis.stackexchange.com has 21,314 questions
r-sig-geo 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
PrintBibliography(my_bib) # RefManageR::WriteBib(my_bib, "refs-geostat.bib")
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.