Learn R Programming

stplanr (version 0.4.0)

route_osrm: Plan a route with OSRM

Description

This is a wrapper around viaroute that returns a single route between A and B.

Usage

route_osrm(from, to, l = NULL, alt = FALSE, ..., singleline = TRUE)

Arguments

from

Text string or coordinates (a numeric vector of length = 2 representing latitude and longitude) representing a point on Earth.

to

Text string or coordinates (a numeric vector of length = 2 representing latitude and longitude) representing a point on Earth. This represents the destination of the trip.

l

Only needed if from and to are empty, in which case this should be a spatial object representing desire lines

alt

Boolean value to return alternative routes (default = TRUE).

...

Arguments passed to viaroute()

singleline

Should a single line be returned? Default is TRUE

See Also

Other routes: line2routeRetry, line2route, nearest2spdf, route_cyclestreet, route_dodgr, route_graphhopper, route_local, route_transportapi_public, route, viaroute2sldf, viaroute

Examples

Run this code
# NOT RUN {
from <- c(-1.55, 53.80) # geo_code("leeds")
to <- c(-1.76, 53.80) # geo_code("bradford uk")
r <- route_osrm(from, to)
plot(r)
r_many <- line2route(flowlines_sf[2:9, ], route_osrm, time_delay = 1)
plot(cents)
plot(r_many$geometry)
# }

Run the code above in your browser using DataLab