Rescale inputs to prepare data for habitat mask to be used.

rescale_classic(X, ext, s.st, site, hab_mask)

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.

ext

An Extent object from the raster package. This is returned from grid_classic.

s.st

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

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

A matrix or arary output from mask_polygon or mask_raster functions.

Value

  • X Rescaled trap coordinates

  • ext Rescaled Extent object from the raster package.

  • s.st A matrix of rescaled starting activity center coordinates.

Details

This function is only meant to be used when habitat masking is incorporated into the model. The functions properly rescales inputs based on the dimensions of the habitat mask. Note that the pixelWidth needs to be included as an input in the model after inputs are rescaled to correctly estimate the scaling parameter (i.e., 'sigma').

Author

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

# add some random noise to locations
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 grid
Grid = grid_classic(X = traps, crs_ = mycrs, buff = 3*mysigma, res = 100)

# create polygon to use as a mask
library(sf)
poly = st_sfc(st_polygon(x=list(matrix(c(-1765,-1765,1730,-1650,1600,1650,
0,1350,-800,1700,-1850,1000,-1765,-1765),ncol=2, byrow=TRUE))), crs =  mycrs)

# make simple plot
par(mfrow=c(1,1))
plot(Grid$grid, pch=20)
points(traps, col="blue",pch=20)
plot(poly, add=TRUE)


# create habitat mask
hab_mask = mask_polygon(poly = poly, grid = Grid$grid, crs_ = mycrs, 
prev_mask = NULL)

# simulate SCR data
data3d = sim_classic(X = traps, ext = Grid$ext, crs_ = mycrs, 
sigma_ = mysigma, prop_sex = 1, N = 200, K = 4, base_encounter = 0.25, 
enc_dist = "binomial", hab_mask = hab_mask, setSeed = 50)

# generate initial activity center coordinates for 2D trap array without 
#habitat mask
s.st3d = initialize_classic(y=data3d$y, M=500, X=traps, ext=Grid$ext, 
hab_mask = hab_mask)

# build rescaled constants list for 2D trap array
constList = rescale_classic(X = traps, ext = Grid$ext, s.st = s.st3d, 
site = NULL, hab_mask = hab_mask)

# inspect list
str(constList)
#> List of 3
#>  $ X   : num [1:25, 1:2] 8.92 13.15 16.79 20.81 24.83 ...
#>   ..- attr(*, "dimnames")=List of 2
#>   .. ..$ : NULL
#>   .. ..$ : chr [1:2] "x" "y"
#>  $ ext :Formal class 'Extent' [package "raster"] with 4 slots
#>   .. ..@ xmin: num 0
#>   .. ..@ xmax: num 34
#>   .. ..@ ymin: num 0
#>   .. ..@ ymax: num 34
#>  $ s.st: num [1:500, 1:2] 18.39 9.05 24.84 18.98 20.99 ...