Learn R Programming

r5r (version 0.7.0)

find_snap: Find snapped locations of input points on street network

Description

R5 tries to snap origin and destination points to the street network in two rounds. First, it uses a search radius of 300 meters. If the first round is unsuccessful, then R5 expands the search radius to 1.6 km. Points that aren't linked to the street network after those two rounds are returned with NA coordinates and found = FALSE. Please note that the location of the snapped points depends on the transport mode set by the user.

Usage

find_snap(r5r_core, points, mode = "WALK")

Arguments

r5r_core

a rJava object to connect with R5 routing engine

points

a spatial sf POINT object, or a data.frame containing the columns 'id', 'lon', 'lat'

mode

string. Defaults to "WALK", also allows "BICYCLE", and "CAR".

Value

A data.table with the original points as well as their respective snapped coordinates on the street network and the Euclidean distance between original points and their respective snapped location. Points that could not be snapped show NA coordinates and found = FALSE.

See Also

Other support functions: assert_breakdown_stat(), assert_decay_function(), assert_points_input(), check_connection(), fileurl_from_metadata(), posix_to_string(), select_mode(), set_max_lts(), set_max_rides(), set_max_street_time(), set_n_threads(), set_progress(), set_speed(), set_suboptimal_minutes(), set_verbose(), stop_r5(), street_network_to_sf(), transit_network_to_sf()

Examples

Run this code
# NOT RUN {
if (interactive()) {

library(r5r)

# build transport network
path <- system.file("extdata/spo", package = "r5r")
r5r_core <- setup_r5(data_path = path, temp_dir = TRUE)

# load origin/destination points
points <- read.csv(file.path(path, "spo_hexgrid.csv"))

# find where origin or destination points are snapped
snap_df <- find_snap(r5r_core,
                     points = points,
                     mode = 'CAR')

stop_r5(r5r_core)
}
# }

Run the code above in your browser using DataLab