ors_matrix: Openrouteservice Matrix

View source: R/matrix.R

ors_matrixR Documentation

Openrouteservice Matrix

Description

Obtain one-to-many, many-to-one and many-to-many matrices for time and distance.

Usage

ors_matrix(
  locations,
  profile = ors_profile(),
  ...,
  api_key = ors_api_key(),
  output = c("parsed", "text")
)

Arguments

locations

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

profile

Route profile, defaults to "driving-car".

...

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

Duration or distance matrix for multiple source and destination

  • for "text", a character vector of length 1 re-encoded to UTF-8.

  • for "parsed", a parsed R object.

Author(s)

Andrzej Oleś andrzej.oles@gmail.com

Examples

coordinates <- list(
  c(9.970093, 48.477473),
  c(9.207916, 49.153868),
  c(37.573242, 55.801281),
  c(115.663757,38.106467)
)

# query for duration and distance in km
res <- ors_matrix(coordinates, metrics = c("duration", "distance"), units = "km")

# duration in hours
res$durations / 3600

# distance in km
res$distances

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