Takes an origin (A) and destination (B), represented by the linestring l, and generates 3 extra geometries based on points p:

line_via(l, p)

Arguments

l

A spatial lines object

p

A spatial points object

Details

  1. From A to P1 (P1 being the nearest point to A)

  2. From P1 to P2 (P2 being the nearest point to B)

  3. From P2 to B

See also

Examples

l <- flowlines_sf[2:4, ] p <- destinations_sf lv <- line_via(l, p) # library(mapview) # mapview(lv) + # mapview(lv$leg_orig, col = "red") library(sf) plot(lv[3], lwd = 9, reset = FALSE)
plot(lv$leg_orig, col = "red", lwd = 5, add = TRUE)
plot(lv$leg_via, col = "black", add = TRUE)
plot(lv$leg_dest, col = "green", lwd = 5, add = TRUE)