Snap coordinates to road network
ors_snap(
locations,
profile = ors_profile(),
radius,
format = c("geojson", "json"),
...,
api_key = ors_api_key(),
output = c("parsed", "text", "sf")
)
List of longitude, latitude
coordinate pairs, alternatively a two column matrix
or data.frame
.
Route profile, defaults to "driving-car"
.
Maximum radius in meters around given coordinates to search for graph edges
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
Coordinates of snapped location(s) and distance to the original point(s) 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{
locations <- list(
c(8.669629, 49.413025),
c(8.675841, 49.418532),
c(8.665144, 49.415594)
)
# query for locations snapped onto the OpenStreetMap road network
res <- ors_snap(locations, radius = 350)
} # }