line_via: Add geometry columns representing a route via intermediary...

View source: R/line_via.R

line_viaR Documentation

Add geometry columns representing a route via intermediary points

Description

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

Usage

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

Other lines: angle_diff(), geo_toptail(), is_linepoint(), line2df(), line2points(), line_bearing(), line_breakup(), line_midpoint(), line_segment1(), line_segment(), mats2line(), n_segments(), n_vertices(), onewaygeo(), points2line(), toptail_buff()

Examples

library(sf)
l <- flowlines_sf[2:4, ]
p <- destinations_sf
lv <- line_via(l, p)
lv
# library(mapview)
# mapview(lv) +
#    mapview(lv$leg_orig, col = "red")
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)

ropensci/stplanr documentation built on March 15, 2024, 4:32 a.m.