Obtain one-to-many, many-to-one and many-to-many matrices for time and distance.
ors_matrix(
locations,
profile = ors_profile(),
...,
api_key = ors_api_key(),
output = c("parsed", "text")
)
List of longitude, latitude
coordinate pairs, alternatively a two column matrix
or data.frame
.
Route profile, defaults to "driving-car"
.
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
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.
# 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(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
} # }