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")
)

Arguments

locations

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

profile

Route profile, defaults to "driving-car".

radius

Maximum radius in meters around given coordinates to search for graph edges

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

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.

Author

Andrzej Oleś andrzej.oles@gmail.com

Examples

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)