Learn R Programming

stplanr (version 0.2.2)

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

alt

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

...

Arguments passed to viaroute()

singleline

Should a single line be returned? Default is TRUE

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)
plot(cents)
plot(r_many, add = TRUE)
# }

Run the code above in your browser using DataLab