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" (destination), and the second object the "from" (source).
This can be used to represent directional SpatialLines
, especially with with arrow heads,
as in Plot(sl, length = 0.1)
.
sp2sl(sp1, from)
caribou <- terra::vect(
x = cbind(
x = stats::runif(1e1, -50, 50),
y = stats::runif(1e1, -50, 50)
)
)
caribouFrom <- terra::vect(
x = cbind(
x = stats::runif(1e1, -50, 50),
y = stats::runif(1e1, -50, 50)
)
)
caribouLines <- sp2sl(caribou, caribouFrom)
if (interactive()) {
clearPlot()
Plot(caribouLines, length = 0.1)
}