Add geometry columns representing a route via intermediary points
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)
l |
A spatial lines object |
p |
A spatial points object |
From A to P1 (P1 being the nearest point to A)
From P1 to P2 (P2 being the nearest point to B)
From P2 to B
Other lines:
angle_diff(),
geo_toptail(),
is_linepoint(),
line2df(),
line2points(),
line_bearing(),
line_breakup(),
line_match(),
line_midpoint(),
line_sample(),
line_segment(),
mats2line(),
n_sample_length(),
n_vertices(),
onewaygeo(),
points2line(),
toptail_buff(),
toptailgs(),
update_line_geometry()
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)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.