Learn R Programming

secrlinear (version 1.2.4)

secrlinear-package: Spatially Explicit Capture--Recapture for Linear Habitats

Description

An secr add-on package for linear habitat models.

Arguments

Author

Murray Efford murray.efford@otago.ac.nz

Details

Package:secrlinear
Type:Package
Version:1.2.4
Date:2024-10-22
License:GNU General Public License Version 2 or later

The important functions in secrlinear are:

read.linearmaskimport and discretize a linear habitat map (route)
networkdistancecompute network distances between detectors and points using a linear habitat mask
sim.linearpopnsimulate population along linear mask
make.lineplace detectors along (part of) a linear route

Other useful functions are:

checkmovescheck capthist object for extreme movements
showpathinteractive examination of network distances
clipmaskdrop mask points outside buffer distance
rbind.linearmaskcombine two linear masks
subset.linearmaskselect part of a linear mask
asgraphconvert linear mask to igraph
snapPointsToLinearMaskclosest point on graph
make.sldfconvert coordinates to SpatialLinesDataFrame

Documentation is provided in a vignette ../doc/secrlinear-vignette.pdf and in the pdf version of the help pages ../doc/secrlinear-manual.pdf

The package draws on the packages sp (Pebesma and Bivand 2005) and igraph (Csardi and Nepusz 2006).

In order to fit a linear-habitat model with the secr function secr.fit:

  1. specify a linear mask for the `mask' argument

  2. specify details = list(userdist = networkdistance) so that secr.fit uses network distances rather than Euclidean distances.

An example dataset arvicola is drawn from trapping of water voles Arvicola amphibius in June 1984 along the River Glyme in the U.K. -- the relevant linear mask is glymemask.

A more complex linear network (Silverstream) is provided as an ESRI shapefile.

References

Csardi, G. and Nepusz, T. (2006) The igraph software package for complex network research. InterJournal, Complex Systems 1695. https://igraph.org/.

Pebesma, E.J. and Bivand, R. S. (2005) Classes and methods for spatial data in R. R News 5(2), https://cran.r-project.org/doc/Rnews/.

See Also

addedges, asgraph, checkmoves, clipmask, deleteedges, linearmask, linearpopn, make.line, make.sldf, networkdistance, plot.linearmask, rbind.linearmask , read.linearmask, showpath, showedges, sim.linearpopn, snapPointsToLinearMask, subset.linearmask

Examples

Run this code

## Water voles in June 1984 on the R. Glyme in Oxfordshire, UK
## capture and trap location files are exactly as for a 2-D analysis

inputdir <- system.file("extdata", package = "secrlinear")
arvicola <- read.capthist(captfile = paste0(inputdir, "/Jun84capt.txt"), 
    trapfile = paste0(inputdir, "/glymetrap.txt"), detector = "multi", 
    covname = "sex")

## Import map of linear habitat
## -- from text file of x-y coordinates
glymemask <- read.linearmask(file = paste0(inputdir, "/glymemap.txt"), spacing = 4)
## -- from a previously constructed SpatialLinesDataFrame
SLDF <- as(sf::st_read(paste0(inputdir,"/glymemap.shp")), 'Spatial')
glymemask <- read.linearmask(data = SLDF, spacing = 4)

## display the mask and capture data
plot (glymemask)
plot(arvicola, add = TRUE, tracks = TRUE)
plot(traps(arvicola), add = TRUE)

## fit model, estimate density
linearfit <- secr.fit(arvicola, mask = glymemask, trace = FALSE,
    details = list(userdist = networkdistance))
predict(linearfit)

## NOTE : the unit of density (D) is animals / km

Run the code above in your browser using DataLab