This will convert 2 objects whose coordinates can be extracted with coordinates
(e.g., sp::SpatialPoints*
)
to a single SpatialLines
object. The first object is treated as the "to" or destination, and the
second object the "from" or source. This can be used to represent
directional SpatialLines, especially with with arrow heads, as in
Plot(sl, length = 0.1)
sp2sl(sp1, from)
sp1 | SpatialPoints* object |
---|---|
from | SpatialPoints* object. Optional. If not provided, then the function
will attempt to find the "previous" coordinates as columns
( |
caribou <- sp::SpatialPoints(coords = cbind(x = stats::runif(1e1, -50, 50), y = stats::runif(1e1, -50, 50))) caribouFrom <- sp::SpatialPoints(coords = cbind(x = stats::runif(1e1, -50, 50), y = stats::runif(1e1, -50, 50))) caribouLines <- sp2sl(caribou, caribouFrom) Plot(caribouLines, length = 0.1)