discretize_classic.Rd
Discretize state-space grid, traps and initial activity center locations to prepare for using in discrete SCR model.
discretize_classic(X, grid, s.st, crs_, site, hab_mask = NULL)
Either a matrix or array representing the coordinates of traps in UTMs. An array is used when traps are clustered over a survey area.
A matrix or array object of the the state-space grid. This is
returned from grid_classic
.
A matrix of starting activity center coordinates. This is
returned from initialize_classic
The UTM coordinate reference system (EPSG code) used for your location provided as an integer (e.g., 32608 for WGS 84/UTM Zone 8N).
Either NULL
(if a 2D trap array is used) or a vector of
integers denoting which trap array an individual (either detected or
augmented) belongs to. Note that site
is provided from
sim_classic
when a 3D trap array is used. However, this
site
variable must be correctly augmented based on the total
augmented population size (i.e., M
).
Either NULL
(the default) or a matrix or array output
from mask_polygon
or mask_raster
functions.
grid
Grid coordinates for the state-space.
nPix
Number of state-space pixels.
X
Discretized traps as a matrix or array.
s.st
Indices for initial activity center locations.
This function prepares the state-space grid, trap coordinates and initial activity center coordinates for use in a discrete spatial capture-recapture model. Note that the number of rows in the state-space grid coordinate matrix will be reduced and this object will need to be adjusted before being used in the model.
The vector s.st
returned from the function indexes the
rows of grid
.
# simulate a single trap array with random positional noise
x <- seq(-800, 800, length.out = 5)
y <- seq(-800, 800, length.out = 5)
traps <- as.matrix(expand.grid(x = x, y = y))
set.seed(200)
traps <- traps + runif(prod(dim(traps)),-20,20)
mysigma = 300 # simulate sigma of 300 m
mycrs = 32608 # EPSG for WGS 84 / UTM zone 8N
# create state-space
Grid = grid_classic(X = traps, crs_ = mycrs, buff = 3*mysigma, res = 100)
# simulate data for uniform state-space and habitat mask
data3d = sim_classic(X = traps, ext = Grid$ext, crs_ = mycrs, sigma_ = mysigma,
prop_sex = 0.7, N = 200, K = 4, base_encounter = 0.15, enc_dist = "binomial",
hab_mask = FALSE, setSeed = 100)
# total augmented population size
M = 400
# get initial activity center starting values
s.st = initialize_classic(y=data3d$y, M=M, X=traps, ext=Grid$ext,
hab_mask = FALSE)
# get discretized traps and initial activity center grid indices
d_list <- discretize_classic(X = traps, grid=Grid$grid,
s.st = s.st, crs_= mycrs,hab_mask=NULL)
str(d_list)
#> List of 4
#> $ grid: num [1:1156, 1:2] -1658 -1558 -1458 -1358 -1258 ...
#> ..- attr(*, "dimnames")=List of 2
#> .. ..$ : NULL
#> .. ..$ : chr [1:2] "x" "y"
#> $ nPix: int 1156
#> $ X : num [1:25, 1:2] -757.7 -357.7 42.3 442.3 842.3 ...
#> ..- attr(*, "dimnames")=List of 2
#> .. ..$ : NULL
#> .. ..$ : chr [1:2] "x" "y"
#> $ s.st: int [1:400] 766 724 736 860 796 705 534 316 662 561 ...