Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

line2route

Convert straight OD data (desire lines) into routes


Description

Convert straight OD data (desire lines) into routes

Usage

line2route(
  l,
  route_fun = stplanr::route_cyclestreets,
  n_print = 10,
  list_output = FALSE,
  l_id = NA,
  time_delay = 0,
  ...
)

Arguments

l

A spatial (linestring) object

route_fun

A routing function to be used for converting the straight lines to routes od2line()

n_print

A number specifying how frequently progress updates should be shown

list_output

If FALSE (default) assumes spatial (linestring) object output. Set to TRUE to save output as a list.

l_id

Character string naming the id field from the input lines data, typically the origin and destination ids pasted together. If absent, the row name of the straight lines will be used.

time_delay

Number or seconds to wait between each query

...

Arguments passed to the routing function, e.g. route_cyclestreets()

Details

See route_cyclestreets() and other route functions for details.

A parallel implementation of this was available until version 0.1.8.

See Also

Examples

## Not run: 
# does not run as requires API key
l <- flowlines[2:5, ]
r <- line2route(l)
rq <- line2route(l = l, plan = "quietest", silent = TRUE)
rsc <- line2route(l = l, route_fun = cyclestreets::journey)
plot(r)
plot(r, col = "red", add = TRUE)
plot(rq, col = "green", add = TRUE)
plot(rsc)
plot(l, add = T)
# Plot for a single line to compare 'fastest' and 'quietest' route
n <- 2
plot(l[n, ])
lines(r[n, ], col = "red")
lines(rq[n, ], col = "green")

## End(Not run)

stplanr

Sustainable Transport Planning

v0.8.2
MIT + file LICENSE
Authors
Robin Lovelace [aut, cre] (<https://orcid.org/0000-0001-5679-6536>), Richard Ellison [aut], Malcolm Morgan [aut] (<https://orcid.org/0000-0002-9488-9183>), Barry Rowlingson [ctb], Nick Bearman [ctb], Nikolai Berkoff [ctb], Scott Chamberlain [rev] (Scott reviewed the package for rOpenSci, see https://github.com/ropensci/onboarding/issues/10), Mark Padgham [ctb], Andrea Gilardi [ctb] (<https://orcid.org/0000-0002-9424-7439>)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.