line2route: Convert straight OD data (desire lines) into routes

Description Usage Arguments Details Examples

View source: R/od-funs.R

Description

Convert straight OD data (desire lines) into routes

Usage

1
2
line2route(l, route_fun = "route_cyclestreet", n_print = 10,
  list_output = FALSE, l_id = NA, ...)

Arguments

l

A SpatialLinesDataFrame

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 SpatialLinesDataFrame 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.

...

Arguments passed to the routing function, e.g. route_cyclestreet

Details

See route_cyclestreet and other route functions for details.

A parallel implementation of this was available until version 0.1.8. See github.com/ropensci/stplanr for details.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
## Not run: 
l = flowlines[2:5,]
r <- line2route(l, "route_osrm")
rf <- line2route(l = l, "route_cyclestreet", plan = "fastest")
rq <- line2route(l = l, plan = "quietest", silent = TRUE)
plot(r)
plot(rf, col = "red", add = TRUE)
plot(rq, col = "green", add = TRUE)
plot(l, add = T)
line2route(flowlines_sf[2:3, ], route_osrm)
# Plot for a single line to compare 'fastest' and 'quietest' route
n = 2
plot(l[n,])
lines(rf[n,], col = "red")
lines(rq[n,], col = "green")
# Example with list output
l <- l[1:3,]
rf_list <- line2route(l = l, list_output = TRUE)
line2route(l[1,], route_graphhopper)

## End(Not run)

stplanr documentation built on Dec. 23, 2017, 5:41 p.m.