rescale_local.Rd
Rescale inputs to prepare data for habitat mask to be used.
rescale_local(X, ext, ext_mat, s.st, site, hab_mask)
An array representing the coordinates of traps in
UTMs for each individual. This is returned from localize_classic
.
An Extent
object from the raster
package. This is
returned from localize_classic
.
A matrix of individual state-space grid extents returned from
localize_classic
.
A matrix of starting activity center coordinates. This is
returned from localize_classic
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
).
A matrix or arary output from mask_polygon
or
mask_raster
functions.
X
Rescaled trap coordinates
ext_mat
Rescaled matrix of individual state-space grid extents.
s.st
A matrix of rescaled starting activity center coordinates.
This function is only meant to be used when habitat masking is
incorporated into a local SCR model. The functions properly rescales inputs for this
SCR approach based onthe 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').
if (FALSE) {
# simulate a single trap array with random positional noise
x <- seq(-1600, 1600, length.out = 6)
y <- seq(-1600, 1600, length.out = 6)
traps <- as.matrix(expand.grid(x = x, y = y))
# add some random noise to locations
set.seed(100)
traps <- traps + runif(prod(dim(traps)),-20,20)
mysigma = 300 # simulate sigma of 300 m
mycrs = 32608 # EPSG for WGS 84 / UTM zone 8N
pixelWidth = 100 # grid resolution
# Simulated abundance
Nsim = 250
# Create initial grid and extent (use a slightly bigger buffer to match
# scaled-up state-space below)
Grid = grid_classic(X = traps, crs_ = mycrs, buff = 3.7*mysigma, res = pixelWidth)
# create polygon to use as a mask
library(sf)
poly = st_sfc(st_polygon(x=list(matrix(c(-2465,-2465,2530,-2550,2650,2550,
0,2550,-800,2500,-2350,2300,-2465,-2465),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 from polygon
hab_mask = mask_polygon(poly = poly, grid = Grid$grid, crs_ = mycrs,
prev_mask = NULL)
data3d = sim_classic(X = traps, ext = Grid$ext, crs_ = mycrs, sigma_ = mysigma,
prop_sex = 1, N = Nsim, K = 4, base_encounter = 0.15,
enc_dist = "binomial", hab_mask = hab_mask, setSeed = 100)
# generate initial activity center coordinates for 2D trap array without
# habitat mask
s.st = initialize_classic(y=data3d$y, M=500, X=traps, ext = Grid$ext,
hab_mask = hab_mask)
# now use grid_classic to create an individual-level state-space (with origin 0, 0)
Grid_ind = grid_classic(X = matrix(c(0,0),nrow=1), crs_ = mycrs,
buff = 3*mysigma, res = 100)
# now localize the data components created above
local_list = localize_classic(y = data3d$y, grid_ind = Grid_ind$grid, X=traps,
crs_ = mycrs, sigma_ = mysigma, s.st = s.st,
hab_mask = hab_mask)
# rescale inputs
rescale_list = rescale_local(X = local_list$X, ext = local_list$ext,
ext_mat = local_list$ext_mat,
s.st = local_list$s.st, hab_mask = hab_mask)
# inspect rescaled list
str(rescale_list)
}