Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

distancetotrap

Distance To Nearest Detector


Description

Compute Euclidean distance from each of a set of points to the nearest detector in an array, or return the sequence number of the detector nearest each point.

Usage

distancetotrap(X, traps)

nearesttrap(X, traps)

Arguments

X

coordinates

traps

traps object or 2-column matrix of coordinates

Details

distancetotrap returns the distance from each point in X to the nearest detector in traps. It may be used to restrict the points on a habitat mask.

For traps objects with polygon detector type (polygon, polygonX), and for SpatialPolygons, the function rgeos::gDistance is used internally if the package rgeos is available (from secr 4.2.0). The method is otherwise approximate and uses only the first polygon.

Value

distancetotrap returns a vector of distances (assumed to be in metres).

nearesttrap returns the index of the nearest trap.

See Also

Examples

## restrict a habitat mask to points within 70 m of traps  
  ## this is nearly equivalent to using make.mask with the 
  ## `trapbuffer' option
  temptrap <- make.grid()
  tempmask <- make.mask(temptrap)
  d <- distancetotrap(tempmask, temptrap)
  tempmask <- subset(tempmask, d < 70)

secr

Spatially Explicit Capture-Recapture

v4.4.1
GPL (>= 2)
Authors
Murray Efford
Initial release
2021-05-01

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.