route_nearest_point: Find nearest route to a given point

View source: R/node-funs.R

route_nearest_pointR Documentation

Find nearest route to a given point

Description

This function was written as a drop-in replacement for sf::st_nearest_feature(), which only works with recent versions of GEOS.

Usage

route_nearest_point(r, p, id_out = FALSE)

Arguments

r

The input route object from which the nearest route is to be found

p

The point whose nearest route will be found

id_out

Should the index of the matching feature be returned? FALSE by default

Examples

r <- routes_fast_sf[2:6, NULL]
p <- sf::st_sfc(sf::st_point(c(-1.540, 53.826)), crs = sf::st_crs(r))
route_nearest_point(r, p, id_out = TRUE)
r_nearest <- route_nearest_point(r, p)
plot(r$geometry)
plot(p, add = TRUE)
plot(r_nearest, lwd = 5, add = TRUE)

stplanr documentation built on Sept. 15, 2023, 9:07 a.m.