Get directions for different modes of transport.
ors_directions(
coordinates,
profile = ors_profile(),
format = c("geojson", "json", "gpx"),
...,
api_key = ors_api_key(),
output = c("parsed", "text", "sf")
)
List of longitude, latitude
coordinate pairs visited in order, alternatively a two column matrix
or data.frame
.
Route profile, defaults to "driving-car"
.
Response format, defaults to "geojson"
Optional parameters as described here
Character scalar containing openrouteservice API key
Output format. By default the response is being parsed to a list-based R object
Route between two or more locations in the selected format
structured according to output
:
for "text"
, a character vector of length 1 re-encoded to UTF-8.
for "parsed"
, a parsed R object.
for "sf"
, a simple features sf
object.
# These examples might require interaction to query the local keyring, or
# might fail due to network issues, so they are not run by default
if (FALSE) { # \dontrun{
coordinates <- list(c(8.34234, 48.23424), c(8.34423, 48.26424))
# simple call
try( ors_directions(coordinates, preference="fastest") )
# customized options
try( ors_directions(coordinates, profile="cycling-mountain", elevation=TRUE) )
# list of locations as `data.frame` output as simple features `sf` object
locations <- data.frame(lng = c(8.34234, 8.327807, 8.34423),
lat = c(48.23424, 48.239368, 48.26424))
try( ors_directions(locations, output = "sf") )
} # }