ors_directions: Openrouteservice Directions

View source: R/directions.R

ors_directionsR Documentation

Openrouteservice Directions

Description

Get directions for different modes of transport.

Usage

ors_directions(
  coordinates,
  profile = ors_profile(),
  format = c("geojson", "json", "gpx"),
  ...,
  api_key = ors_api_key(),
  output = c("parsed", "text", "sf")
)

Arguments

coordinates

List of ⁠longitude, latitude⁠ coordinate pairs visited in order, alternatively a two column matrix or data.frame.

profile

Route profile, defaults to "driving-car".

format

Response format, defaults to "geojson"

...

Optional parameters as described here

api_key

Character scalar containing openrouteservice API key

output

Output format. By default the response is being parsed to a list-based R object

Value

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.

Author(s)

Andrzej Oleś andrzej.oles@gmail.com

Examples

coordinates <- list(c(8.34234, 48.23424), c(8.34423, 48.26424))

# simple call
ors_directions(coordinates, preference="fastest")

# customized options
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))
ors_directions(locations, output = "sf")

openrouteservice documentation built on Oct. 21, 2024, 9:06 a.m.