stplanr (version 0.6.2)

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

Other routes: line2routeRetry(), route_dodgr(), route_graphhopper(), route_local(), route_transportapi_public(), route()

Examples

Run this code
# 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")
# }

Run the code above in your browser using DataLab