discretize_classic: Discretize traps and initial activity centers

View source: R/localSCR.R

discretize_classicR Documentation

Discretize traps and initial activity centers

Description

Discretize state-space grid, traps and initial activity center locations to prepare for using in discrete SCR model.

Usage

discretize_classic(X, grid, s.st, crs_, site, hab_mask = NULL)

Arguments

X

Either a matrix or array representing the coordinates of traps in UTMs. An array is used when traps are clustered over a survey area.

grid

A matrix or array object of the the state-space grid. This is returned from grid_classic.

s.st

A matrix of starting activity center coordinates. This is returned from initialize_classic

crs_

The UTM coordinate reference system (EPSG code) used for your location provided as an integer (e.g., 32608 for WGS 84/UTM Zone 8N).

site

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).

hab_mask

Either NULL (the default) or a matrix or array output from mask_polygon or mask_raster functions.

Details

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.

Value

  • 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.

Note

The vector s.st returned from the function indexes the rows of grid.

Author(s)

Daniel Eacker

Examples

# 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)

sitkensis22/localSCR documentation built on May 15, 2022, 5:26 p.m.