- Background
- Using stplanr
- Future plans
Presented in Poznan at eRum, 2016-10-13

Common computational tasks in transportation planning:
Transport planning is notoriously reliant on 'black boxes' and the same applies to scientific research into transport systems [@Waddell2002].
stplanr seeks to address these issues.
stplanr lives here: https://github.com/ropensci/stplanr
Package can be installed from CRAN or GitHub (see the package's README for details), it can be loaded in with library():
install.packages("stplanr") # stable CRAN version
devtools::install_github("ropensci/stplanr") # dev version
library(stplanr)
Use
@importFromwhenever possible. Right now you haveimport(openxlsx)andimport(sp)in your NAMESPACE file. Just import the functions you need. Same for other pkg deps.
Tests: Pleae write tests to cover at least all the major functions before we accept. Use
testthat::skip_on_cran()for any tests that do web requests, so that CRAN tests don't fail in case a service is temporarily down
I think token's can be a bit easier for the user. Right now you have e.g.,
if (!Sys.getenv('CYCLESTREET') == "") {
cckey <- Sys.getenv('CYCLESTREET')
}
if(is.null(cckey)){
stop("You must have a CycleStreets.net api key saved as 'cckey'")
}
| cents | SpatialPointsDataFrame.of.home.locations.for.flow.analysis. |
|---|---|
| destination_zones | example destinations data |
| destinations | example destinations data |
| flow | data frame of commuter flows |
| flow_dests | data frame of invented commuter flows with destinations in a different layer than the origins |
| flowlines | SpatialLinesDataFrame of commuter flows |
| routes_fast | SpatialLinesDataFrame of commuter flows on the travel network |
| routes_slow | SpatialLinesDataFrame of commuter flows on the travel network |
| zones | SpatialPolygonsDataFrame of home locations for flow analysis. |
data("flow", package = "stplanr")
head(flow[c(1:3, 12)])
## Area.of.residence Area.of.workplace All Bicycle ## 920573 E02002361 E02002361 109 2 ## 920575 E02002361 E02002363 38 0 ## 920578 E02002361 E02002367 10 0 ## 920582 E02002361 E02002371 44 3 ## 920587 E02002361 E02002377 34 0 ## 920591 E02002361 E02002382 7 0
data("cents", package = "stplanr")
as.data.frame(cents[1:3,-c(3,4)])
## geo_code MSOA11NM coords.x1 coords.x2 ## 1708 E02002384 Leeds 055 -1.546463 53.80952 ## 1712 E02002382 Leeds 053 -1.511861 53.81161 ## 1805 E02002393 Leeds 064 -1.524205 53.80410
l <- od2line(flow = flow, zones = cents) # remove lines with no length l <- l[!l$Area.of.residence == l$Area.of.workplace,] plot(l, lwd = l$All / 10)
stplanr has various functions for route allocation:
route_cyclestreet() # UK, cycling route_graphhopper() # worldwide, any mode route_transportapi_public() # UK, public transport viaroute() # worldwide, any mode
r = route_graphhopper(from = "Leeds", to = "Poznan", vehicle = "bike")
library(leaflet) leaflet() %>% addTiles() %>% addPolylines(data = r)
routes_fast = line2route(l = l)
plot(l) plot(routes_fast, add = T, col = "red")
Download and test the dev version with:
Academic paper on the PCT: http://arxiv.org/abs/1509.04425