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

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

Note

The public-facing OSRM routing service (the default) only provides routing for cars by default. For details, see https://github.com/Project-OSRM/osrm-backend/issues/4530.

See also

Examples

if (FALSE) { 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) }