SpaDES (version 1.1.4)

makeLines: Make SpatialLines object from two SpatialPoints objects

Description

The primary conceived usage of this is to draw arrows following the trajectories of agents.

Usage

makeLines(from, to)

## S3 method for class 'SpatialPoints,SpatialPoints': makeLines(from, to)

Arguments

from
Starting spatial coordinates (SpatialPointsDataFrame).
to
Ending spatial coordinates (SpatialPointsDataFrame).

Value

  • A SpatialLines object. When this object is used within a Plot call and the length argument is specified, then arrow heads will be drawn. See examples.

Examples

Run this code
library(sp)
# Make 2 objects
caribou1 <- SpatialPoints(cbind(x=stats::runif(10, -50, 50), y=stats::runif(10, -50, 50)))
caribou2 <- SpatialPoints(cbind(x=stats::runif(10, -50, 50), y=stats::runif(10, -50, 50)))

caribouTraj <- makeLines(caribou1, caribou2)
Plot(caribouTraj, new=TRUE, length=0.1)

# or  to a previous Plot
filelist <- data.frame(files =
     dir(file.path(find.package("SpaDES",
                                lib.loc=getOption("devtools.path"),
                                quiet=FALSE),
                  "maps"),
        full.names=TRUE, pattern= "tif"),
     functions="rasterToMemory",
     packages="SpaDES")

# Load files to memory (using rasterToMemory)
sim1 <- loadFiles(filelist=filelist)

Plot(sim1$DEM, new=TRUE)
caribouTraj <- makeLines(caribou1, caribou2)
Plot(caribouTraj, addTo="sim1$DEM", length=0.1)

Run the code above in your browser using DataLab