stplanr
A package for sustainable transport planning with R.
https://github.com/ropensci/stplanr
Category: Consumption
Sub Category: Mobility and Transportation
Keywords
cycle cycling desire-lines origin-destination peer-reviewed pubic-transport r r-package route-network routes routing rstats spatial transport transport-planning transportation walking
Keywords from Contributors
geos geocoding tidyverse book gdal rspatial genome weather occurrences proj
Last synced: about 17 hours ago
JSON representation
Repository metadata
Sustainable transport planning with R
- Host: GitHub
- URL: https://github.com/ropensci/stplanr
- Owner: ropensci
- License: other
- Created: 2015-01-30T08:34:49.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2025-04-17T22:11:30.000Z (9 days ago)
- Last Synced: 2025-04-18T21:33:56.557Z (8 days ago)
- Topics: cycle, cycling, desire-lines, origin-destination, peer-reviewed, pubic-transport, r, r-package, route-network, routes, routing, rstats, spatial, transport, transport-planning, transportation, walking
- Language: R
- Homepage: https://docs.ropensci.org/stplanr
- Size: 25.7 MB
- Stars: 426
- Watchers: 20
- Forks: 67
- Open Issues: 22
- Releases: 44
-
Metadata Files:
- Readme: README.Rmd
- Changelog: NEWS.md
- License: LICENSE
README.Rmd
--- output: github_document --- ```{r setup, include = FALSE} knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" ) ``` # stplanr[](https://github.com/r-hub/cranlogs.app) [](https://cran.r-project.org/package=stplanr) [](https://cran.r-project.org/package=stplanr) [](https://lifecycle.r-lib.org/articles/stages.html) [](https://github.com/ropensci/software-review/issues/10) [](https://github.com/ropensci/stplanr/actions/workflows/R-CMD-check.yaml) ```{r, echo=FALSE, message=FALSE, warning=FALSE} library(stplanr) ``` **stplanr** is a package for sustainable transport planning with R. It provides functions for solving common problems in transport planning and modelling, such as how to best get from point A to point B. The overall aim is to provide a reproducible, transparent and accessible toolkit to help people better understand transport systems and inform policy, as outlined in a [paper](https://journal.r-project.org/archive/2018/RJ-2018-053/index.html) about the package, and the potential for open source software in transport planning in general, published in the [R Journal](https://journal.r-project.org/). The initial work on the project was funded by the Department of Transport ([DfT](https://www.gov.uk/government/organisations/department-for-transport)) as part of the development of the Propensity to Cycle Tool (PCT), a web application to explore current travel patterns and cycling potential at zone, desire line, route and route network levels (see [www.pct.bike](https://www.pct.bike/) and click on a region to try it out). The basis of the methods underlying the PCT is origin-destination data, which are used to highlight where many short distance trips are being made, and estimate how many could switch to cycling. The results help identify where cycleways are most needed, an important component of sustainable transport planning infrastructure engineering and policy design. See the package vignette (e.g. via `vignette("introducing-stplanr")`) or an [academic paper on the Propensity to Cycle Tool (PCT)](https://dx.doi.org/10.5198/jtlu.2016.862) for more information on how it can be used. This README provides some basics. Much of the work supports research undertaken at the Leeds' Institute for Transport Studies ([ITS](https://environment.leeds.ac.uk/transport)) but **stplanr** should be useful to transport researchers and practitioners needing free, open and reproducible methods for working with geographic data everywhere. ## Key functions Data frames representing flows between origins and destinations must be combined with geo-referenced zones or points to generate meaningful analyses and visualisations of 'flows' or origin-destination (OD) data. **stplanr** facilitates this with `od2line()`, which takes flow and geographical data as inputs and outputs spatial data. Some example data is provided in the package: ```{r, results='hide', message=FALSE} library(stplanr) ``` Let's take a look at this data: ```{r} od_data_sample[1:3, 1:3] # typical form of flow data cents_sf[1:3,] # points representing origins and destinations ``` These datasets can be combined as follows: ```{r plot1, warning=FALSE} travel_network <- od2line(flow = od_data_sample, zones = cents_sf) w <- flow$all / max(flow$all) *10 plot(travel_network, lwd = w) ``` **stplanr** has many functions for working with OD data. See the [`stplanr-od`](https://docs.ropensci.org/stplanr/articles/stplanr-od.html) vignette for details. The package can also allocate flows to the road network, e.g. with [CycleStreets.net](https://www.cyclestreets.net/api/) and the OpenStreetMap Routing Machine ([OSRM](https://github.com/Project-OSRM/osrm-backend)) API interfaces. These are supported in `route_*()` functions such as `route_cyclestreets` and `route_osrm()`: Routing can be done using a range of back-ends and using lat/lon or desire line inputs with the `route()` function, as illustrated by the following commands which calculates the route between Fleet Street and Southwark Street over the River Thames on Blackfriars Bridge in London: ```{r, eval=FALSE, echo=FALSE} tmaptools::geocode_OSM("fleet street london") tmaptools::geocode_OSM("southwark street london") ``` ```{r} library(osrm) trip <- route( from = c(-0.11, 51.514), to = c(-0.10, 51.506), route_fun = osrmRoute, returnclass = "sf" ) plot(trip) ``` You can also use and place names, found using the Google Map API: ```{r cycle-trip, message=FALSE, warning=FALSE, eval=FALSE, echo=FALSE} if(!Sys.getenv("CYCLESTREETS") == ""){ trip <- route_cyclestreets("Bradford, UK", "Leeds, Yorkshire", plan = "balanced") plot(trip) } ``` ```{r} trip2 <- route( from = "Leeds", to = "Bradford", route_fun = osrmRoute, returnclass = "sf" ) plot(trip2) ``` We can replicate this call multiple times with the `l` argument in `route()`: ```{r} desire_lines <- travel_network[2:6, ] ``` ```{r, echo=FALSE} # Sys.sleep(2) # wait a moment ``` Next, we'll calculate the routes: ```{r plot2, results='hide', message=FALSE} routes <- route( l = desire_lines, route_fun = osrmRoute, returnclass = "sf" ) plot(sf::st_geometry(routes)) plot(desire_lines, col = "red", add = TRUE) ``` ```{r routes, echo=FALSE, eval=FALSE} lwd <- desire_lines$foot routes <- routes_fast_sf[2:6, ] plot(routes$geometry, lwd = lwd) plot(desire_lines$geometry, col = "green", lwd = lwd, add = TRUE) ``` For more examples, `example("route")`. `overline()` takes a series of route-allocated lines, splits them into unique segments and aggregates the values of overlapping lines. This can represent where there will be most traffic on the transport system, as demonstrated in the following code chunk. ```{r rnet, warning=FALSE} routes$foot <- desire_lines$foot rnet <- overline(routes, attrib = "foot") ``` The resulting route network, with segment totals calculated from overlapping parts for the routes for walking, can be visualised as follows: ```{r} plot(rnet["foot"], lwd = rnet$foot) ``` The above plot represents the number walking trips made (the 'flow') along particular segments of a transport network. ```{r, routes-leaf, eval=FALSE, echo=FALSE} library(leaflet) pal = leaflet::colorNumeric(palette = "YlGnBu", domain = rnet$all) leaflet(data = rnet) %>% addProviderTiles(providers$OpenStreetMap.BlackAndWhite) %>% addPolylines(weight = rnet$all / 3, color = ~pal(all), opacity = 0.9) %>% addLegend(pal = pal, values = ~all) ``` ## Policy applications The examples shown above, based on tiny demonstration datasets, may not seem particularly revolutionary. At the city scale, however, this type of analysis can be used to inform sustainable transport policies, as described in papers [describing the Propensity to Cycle Tool](https://www.jtlu.org/index.php/jtlu/article/view/862/859) (PCT), and its [application to calculate cycling to school potential](https://doi.org/10.1016/j.jth.2019.01.008) across England. Results generated by **stplanr** are now part of national government policy: the PCT is the recommended tool for local and regional authorities developing strategic cycle network under the Cycling and Walking Infrastructure Strategy ([CWIS](https://www.gov.uk/government/publications/cycling-and-walking-investment-strategy)), which is part of the Infrastructure Act [2015](https://www.legislation.gov.uk/ukpga/2015/7/contents/enacted). **stplanr** is helping dozens of local authorities across the UK to answer the question: where to prioritise investment in cycling? In essence, stplanr was designed to support sustainable transport policies. There are many other research and policy questions that functions in **stplanr**, and other open source software libraries and packages, can help answer. At a time of climate, health and social crises, it is important that technology is not only sustainable itself (e.g. as enabled by open source communities and licenses) but that it contributes to a sustainable future. ## Installation To install the stable version, use: ```{r, eval=FALSE} install.packages("stplanr") ``` The development version can be installed using **devtools**: ```{r, eval=FALSE} # install.packages("devtools") # if not already installed devtools::install_github("ropensci/stplanr") library(stplanr) ``` ### Installing stplanr on Linux and Mac **stplanr** depends on **sf**. Installation instructions for Mac, Ubuntu and other Linux distros can be found here: https://github.com/r-spatial/sf#installing ## Funtions, help and contributing The current list of available functions can be seen on the package's website at [docs.ropensci.org/stplanr/](https://docs.ropensci.org/stplanr/), or with the following command: ```{r, eval=FALSE} lsf.str("package:stplanr", all = TRUE) ``` To get internal help on a specific function, use the standard way. ```{r, eval=FALSE} ?od2line ``` To contribute, report bugs or request features, see the [issue tracker](https://github.com/ropensci/stplanr/issues). ```{r, eval=FALSE, echo=FALSE} # Aim: explore dependencies desc = read.dcf("DESCRIPTION") headings = dimnames(desc)[[2]] fields = which(headings %in% c("Depends", "Imports", "Suggests")) pkgs = paste(desc[fields], collapse = ", ") pkgs = gsub("\n", " ", pkgs) strsplit(pkgs, ",")[[1]] install.packages("miniCRAN") library(miniCRAN) tags <- "stplanr" pkgDep(tags) dg <- makeDepGraph(tags, enhances = TRUE) set.seed(1) plot(dg, legendPosition = c(-1, 1), vertex.size = 20) library(DiagrammeR) DiagrammeR::visnetwork(dg) visNetwork::visIgraph(dg) ``` ## Further resources / tutorials Want to learn how to use open source software for reproducible sustainable transport planning work? Now is a great time to learn. Transport planning is a relatively new field of application in R. However, there are already some good resources on the topic, including (any further suggestions: welcome): - The Transport chapter of *Geocomputation with R*, which provides a broad introduction from a geographic data perspective: https://r.geocompx.org/transport.html - The **stplanr** paper, which describes the context in which the package was developed: https://journal.r-project.org/archive/2018/RJ-2018-053/index.html (please cite this if you use **stplanr** in your work) - The `dodgr` vignette, which provides an introduction to routing in R: https://github.com/UrbanAnalyst/dodgr ## Meta * Please report issues, feature requests and questions to the [github issue tracker](https://github.com/ropensci/stplanr/issues) * License: MIT * Get citation information for **stplanr** in R doing `citation(package = 'stplanr')` * This project is released with a [Contributor Code of Conduct](https://github.com/ropensci/stplanr/blob/master/CONDUCT.md). By participating in this project you agree to abide by its terms. [](https://ropensci.org)
Owner metadata
- Name: rOpenSci
- Login: ropensci
- Email: [email protected]
- Kind: organization
- Description:
- Website: https://ropensci.org/
- Location: Berkeley, CA
- Twitter: rOpenSci
- Company:
- Icon url: https://avatars.githubusercontent.com/u/1200269?v=4
- Repositories: 307
- Last ynced at: 2023-03-10T20:30:59.242Z
- Profile URL: https://github.com/ropensci
GitHub Events
Total
- Issues event: 15
- Watch event: 9
- Issue comment event: 26
- Push event: 6
- Pull request review event: 1
- Pull request event: 2
- Fork event: 1
- Create event: 1
Last Year
- Issues event: 15
- Watch event: 9
- Issue comment event: 26
- Push event: 6
- Pull request review event: 1
- Pull request event: 2
- Fork event: 1
- Create event: 1
Committers metadata
Last synced: 4 days ago
Total Commits: 1,844
Total Committers: 35
Avg Commits per committer: 52.686
Development Distribution Score (DDS): 0.16
Commits in past year: 45
Committers in past year: 3
Avg Commits per committer in past year: 15.0
Development Distribution Score (DDS) in past year: 0.067
Name | Commits | |
---|---|---|
Robin Lovelace | r****x@g****m | 1549 |
Richard Ellison | r****n@i****u | 136 |
Malcolm Morgan | m****8 | 40 |
mpadge | m****m@e****m | 19 |
Andrea | a****3@g****m | 15 |
Nikolai B | n****b | 14 |
Andrea Gilardi | a****5@c****t | 11 |
wangzhao0217 | w****7@g****m | 9 |
Karthik Ram | k****m@g****m | 7 |
Layik Hama | l****a@g****m | 4 |
Maëlle Salmon | m****n@y****e | 4 |
mvl22 | m****n@l****k | 3 |
steven2249 | s****w@b****u | 3 |
RFlx | 3****a | 2 |
Josiah Parry | j****y@g****m | 2 |
Edzer Pebesma | e****a@u****e | 2 |
Scott Chamberlain | m****s@g****m | 2 |
ilanfri | i****i@m****m | 2 |
usr110 | m****s@g****m | 2 |
jn | t****i@g****m | 2 |
Matthew Petersen | m****n@g****m | 2 |
seanolondon | S****l@l****k | 1 |
Malcolm Morgan | m****2@h****m | 1 |
Nick Bearman | n****n@g****m | 1 |
meptrsn | m****w@m****o | 1 |
timpearson99 | t****n@c****k | 1 |
unknown | r****e@F****u | 1 |
virgesmith | a****h@l****k | 1 |
munterfinger | l****n@h****h | 1 |
hxd1011 | h****1@g****m | 1 |
and 5 more... |
Committer domains:
- cs.man.ac.uk: 1
- hispeed.ch: 1
- leeds.ac.uk: 1
- feb3327.econ.usyd.edu.au: 1
- campus-10-41-102-49.wireless.leeds.ac.uk: 1
- meptrsn.info: 1
- london.gov.uk: 1
- mac.com: 1
- uni-muenster.de: 1
- berkeley.edu: 1
- lucas-smith.co.uk: 1
- campus.unimib.it: 1
- email.com: 1
- itls.usyd.edu.au: 1
Issue and Pull Request metadata
Last synced: 1 day ago
Total issues: 272
Total pull requests: 291
Average time to close issues: 5 months
Average time to close pull requests: 7 days
Total issue authors: 55
Total pull request authors: 27
Average comments per issue: 4.26
Average comments per pull request: 1.38
Merged pull request: 264
Bot issues: 0
Bot pull requests: 1
Past year issues: 14
Past year pull requests: 4
Past year average time to close issues: about 6 hours
Past year average time to close pull requests: about 3 hours
Past year issue authors: 3
Past year pull request authors: 2
Past year average comments per issue: 2.36
Past year average comments per pull request: 1.0
Past year merged pull request: 4
Past year bot issues: 0
Past year bot pull requests: 0
Top Issue Authors
- Robinlovelace (172)
- agila5 (8)
- mem48 (7)
- wangzhao0217 (6)
- maelle (5)
- rsbivand (5)
- sckott (5)
- JimShady (3)
- joeytalbot (3)
- mvl22 (3)
- richardellison (3)
- mpadge (3)
- JosiahParry (2)
- nikolai-b (2)
- meptrsn (2)
Top Pull Request Authors
- Robinlovelace (160)
- richardellison (65)
- mpadge (11)
- mem48 (8)
- wangzhao0217 (6)
- agila5 (6)
- maelle (5)
- nikolai-b (5)
- JosiahParry (2)
- Nowosad (2)
- karthik (2)
- sckott (2)
- edzer (2)
- temospena (2)
- munterfi (1)
Top Issue Labels
- help wanted (9)
- enhancement (6)
- good first issue (6)
- ro-hackathon-2025 (5)
- bug (4)
- Needs documentation (1)
Top Pull Request Labels
- dependencies (1)
Package metadata
- Total packages: 1
-
Total downloads:
- cran: 1,373 last-month
- Total docker downloads: 89,487
- Total dependent packages: 3
- Total dependent repositories: 8
- Total versions: 53
- Total maintainers: 1
cran.r-project.org: stplanr
Sustainable Transport Planning
- Homepage: https://github.com/ropensci/stplanr
- Documentation: http://cran.r-project.org/web/packages/stplanr/stplanr.pdf
- Licenses: MIT + file LICENSE
- Latest release: 1.2.3 (published 6 days ago)
- Last Synced: 2025-04-25T13:05:59.265Z (1 day ago)
- Versions: 53
- Dependent Packages: 3
- Dependent Repositories: 8
- Downloads: 1,373 Last month
- Docker Downloads: 89,487
-
Rankings:
- Docker downloads count: 0.018%
- Stargazers count: 0.9%
- Forks count: 1.004%
- Average: 5.391%
- Downloads: 9.201%
- Dependent repos count: 10.588%
- Dependent packages count: 10.637%
- Maintainers (1)
Dependencies
- leaflet ~0.7.3
- R >= 3.5.0 depends
- Rcpp >= 0.12.1 imports
- curl >= 3.2 imports
- data.table * imports
- dplyr >= 0.7.6 imports
- httr >= 1.3.1 imports
- jsonlite >= 1.5 imports
- lwgeom >= 0.1.4 imports
- magrittr * imports
- methods * imports
- nabor >= 0.5.0 imports
- od * imports
- pbapply * imports
- rlang >= 0.2.2 imports
- sf >= 0.6.3 imports
- sfheaders * imports
- cyclestreets * suggests
- dodgr >= 0.2.15 suggests
- geodist * suggests
- igraph >= 1.2.2 suggests
- knitr >= 1.20 suggests
- leaflet * suggests
- mapsapi * suggests
- opentripplanner * suggests
- osrm * suggests
- pct * suggests
- rmarkdown >= 1.10 suggests
- testthat >= 2.0.0 suggests
- tmap * suggests
- chai ^2.3.0 development
- eslint ^2.7.0 development
- eslint-plugin-html ^1.4.0 development
- mocha ^2.2.4 development
- mocha-phantomjs ^3.5.3 development
- mversion ^2.0.0 development
- phantomjs 1.9.7-15 development
- uglify-js ^2.4.15 development
- actions/checkout v3 composite
- r-lib/actions/check-r-package v2 composite
- r-lib/actions/setup-pandoc v2 composite
- r-lib/actions/setup-r v2 composite
- r-lib/actions/setup-r-dependencies v2 composite
- actions/checkout v1 composite
- actions/checkout master composite
- r-lib/actions/pr-fetch master composite
- r-lib/actions/pr-push master composite
- r-lib/actions/setup-r master composite
Score: 21.07739251280622