make.spcosa | R Documentation |
A spatial coverage design places one cluster of detectors in each compact subregion of a region of interest. Equal subregions are determined by k-means clustering of pixels (Walvoort et al. 2010).
make.spcosa(n, cluster, region, rotation = 0, randomize = FALSE, maxtries = 100,
keep.mask = FALSE, ...)
n |
integer number of subregions |
cluster |
traps object defining a cluster of detectors |
region |
boundary of region of interest |
rotation |
numeric angular rotation of each cluster (negative for random) |
randomize |
logical; if TRUE then cluster is located at random within subregion |
maxtries |
integer maximum attempts to find random location |
keep.mask |
logical; if TRUE then a habitat mask with covariate ‘stratum’ |
... |
other arguments passed to |
The region may be specified in any form acceptable as the ‘poly’ argument of make.mask
(see also boundarytoSF).
The ... argument determines the coarseness of the discretization used to define the subregions, via the ‘nx’ or ‘spacing’ arguments of make.mask
.
By default (randomize = FALSE) clusters are centred at subregion centroids. Otherwise (randomize = TRUE) clusters are centred in a randomly selected cell of each subregion, subject to the constraint that all detectors fall within the subregion. An error results if no cluster meeting the constraint is found in ‘maxtries’ attempts.
Slightly different partitions of ‘poly’ are generated depending on the value of the random seed, so for consistency this should be first set with set.seed
.
The argument ‘rotation’ is applied separately to each cluster, as in trap.builder
and unlike the argument ‘rotate’ of make.systematic
.
A traps object with n x nrow(cluster) detectors.
Walvoort, D., Brus, D., and de Gruijter, J. (2010) An R package for spatial coverage sampling and random sampling from compact geographical strata by k-means. Computers & Geosciences 36:1261–1267.
make.mask
,
trap.builder
,
boundarytoSF
,
traps
# preliminaries
polygonfile <- system.file("extdata/possumarea.txt", package = "secr")
poly <- read.table(polygonfile, header = TRUE)
subgrid <- make.grid(3,3, spacing = 80)
set.seed(123)
# nx and keep.mask refer to the discretized region of interest
tr <- make.spcosa(n = 5, subgrid, poly, nx = 32, randomize = TRUE,
keep.mask = TRUE)
plot(attr(tr,'mask'), dots = FALSE, cov = 'stratum', legend = FALSE)
plot(tr, add = TRUE)
lines(poly)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.