Skip to contents

Queries the snap endpoint to snap source points to the nearest accessible street.

Usage

ors_snap(src, profile = NULL, radius = 350, instance = NULL, ...)

Arguments

src

[sf/sfc]

Source dataset containing point geometries that should be routed from.

profile

[character]

Means of transport as supported by OpenRouteService. Defaults to the first profile in a call to get_profiles. For ors_shortest_distances, profile can be a character vector, for all other functions it needs to be a character scalar. For details on all profiles, refer to the backend reference.

radius

[numeric]

Snapping radius. Points are only snapped to a street if the street lies within this distance to the source point.

instance

[ors_instance]

Object of an OpenRouteService instance that should be used for route computations. It is recommended to use ors_instance to set an instance globally. This argument should only be used if activating an instance globally is not feasible.

...

Additional arguments passed to the snap API.

Value

A dataframe containing the snapped geometries of each point in src together with the name of the street and the snapping distance.

Examples

if (FALSE) { # \dontrun{
plot(pharma, col = "black")

snap1 <- ors_snap(pharma)
plot(snap1, add = TRUE, col = "red")

snap2 <- ors_snap(pharma, radius = 5000)
plot(snap2, add = TRUE, col = "blue")

snap3 <- ors_snap(pharma, profile = "foot-walking")
plot(snap3, add = TRUE, col = "green")
} # }