PG: Telemetry Fixes in Polygons

Description Usage Arguments Details Value References See Also Examples

Description

For a telemetry dataset, either as a standalone capthist object with detector type ‘telemetryonly’ or the xylist attribute of a combined capthist object resulting from addTelemetry, determine the proportion of fixes of each individual that lie within a set of polygons. Typically used to obtain the proportion of fixes on a trapping grid, hence ‘proportion on grid’.

Usage

1
PG(CH, poly = NULL, includeNULL = FALSE, plt = FALSE, ...)

Arguments

CH

capthist object including telemetry locations

poly

SpatialPolygonsDataFrame object from sp

includeNULL

logical; if TRUE then missing values are returned for animals without telemetry data

plt

logical; if TRUE then poly and telemetry locations are plotted

...

other arguments passed to buffer.contour

Details

By default poly is obtained by applying buffer.contour with arguments ... to the traps attribute of CH. Note that either a positive buffer argument or convex = TRUE is needed for the polygon to have area > 0.

If plt = TRUE, buffer.contour is used to plot poly and the points are overplotted (open circles outside, filled circles inside). To control the framing of the plot, create an initial plot (e.g., with plot.traps, setting the border argument) and use add = TRUE (see Examples).

Value

Numeric vector of proportions. If includeNULL = TRUE length equal to number of animals (rows) in CH; otherwise length is the number of animals for which there is telemetry data (because xylist may cover only a subset of animals in CH).

References

Grant, T. J. and Doherty, P. F. (2007) Monitoring of the flat-tailed horned lizard with methods incorporating detection probability. Journal of Wildlife Management 71, 1050–1056

See Also

addTelemetry, buffer.contour, SpatialPolygonsDataFrame, pointsInPolygon

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
## Not run: 
olddir <- setwd('d:/density communication/combining telemetry and secr/possums')
CvilleCH <- read.capthist('CVILLE summer captures 4occ.txt',
                          'CVILLE detectors summer 4occ.txt',
                          detector = 'single')
CvilleGPS <- read.telemetry('CVILLE GPS Combined 4occ.txt')
CvilleGPSnew <- read.telemetry('CVILLE summer GPS New occasions.txt')
setwd(olddir)

CvilleBoth <- addTelemetry(CvilleCH, CvilleGPSnew)
plot(CvilleBoth, border = 400)
PG(CvilleBoth, buffer = 100, convex = TRUE, plt = TRUE, add = TRUE, 
    col = 'red')

###################################################################
## this code computes an area-adjusted density estimate
## cf Grant and Doherty 2007
PGD <- function (CH, estimator = 'h2', ...) {
    pg <- PG(CH, ...)
    PGbar <- mean(pg)
    N <- closedN(CH, estimator)
    A <- polyarea(buffer.contour(traps(CH), ...)[[1]])
    Dhat <- N$Nhat / A * PGbar
    varDhat <- (N$Nhat^2 * var(pg) + PGbar^2 * N$seNhat^2) / A^2 
    c(Dhat = Dhat, seDhat = sqrt(varDhat))
}
plot(traps(CvilleBoth), border = 400)
PGD(CvilleBoth, buffer = 0, convex = TRUE, plt = TRUE, add = TRUE)
PGD(CvilleBoth, est='null', buffer = 0, convex = TRUE, plt = FALSE)

###################################################################
## this code generates a PG summary for telemetry records randomly
## translated and rotated, keeping the centres within a habitat mask

randomPG <- function(CH, poly = NULL, mask, reorient = TRUE, nrepl = 1,
                     seed = 12345, ...) {
    moveone <- function(xy, newcentre) {
        xy <- sweep(xy,2,apply(xy,2,mean))
        if (reorient)  ## random rotation about centre
            xy <- rotate(xy, runif(1)*360)
        sweep(xy,2,unlist(newcentre), "+")
    }
    onerepl <- function(r) {   ## r is dummy for replicate
        centres <- sim.popn(D = D, core = mask, model2D = "IHP",
                            Ndist = "fixed")
        xyl <- mapply(moveone, xyl, split(centres, rownames(centres)))
        attr(CH, 'xylist') <- xyl  ## substitute random placement
        PG(CH = CH , poly = poly, plt = FALSE, ...)
    }
    set.seed(seed)
    require(sp)
    if (is.null(poly)) {
        poly <- buffer.contour (traps(CH), ...)
        srl <- lapply(poly, function(x) Polygon(as.matrix(x)))
        tmp <- Polygons(srl,1)
        poly <- SpatialPolygons(list(tmp))
        poly <- SpatialPolygonsDataFrame(poly, data = data.frame(ID =
                                               names(poly)))
    }
    xyl <- telemetryxy(CH)
    D <- length(xyl) / maskarea(mask)
    sapply(1:nrepl, onerepl)
}

mask <- make.mask (traps(CvilleBoth), buffer = 400, type = "trapbuffer")
require(sp)
pg <- randomPG (CvilleBoth, mask = mask, buffer = 100, convex = TRUE,
    nrepl = 20)
apply(pg, 1, mean)
###################################################################


## End(Not run)

secr documentation built on Oct. 18, 2021, 9:06 a.m.