rescale_local | R Documentation |
Rescale inputs to prepare data for habitat mask to be used.
rescale_local(X, ext, ext_mat, s.st, site, hab_mask)
X |
An array representing the coordinates of traps in
UTMs for each individual. This is returned from |
ext |
An |
ext_mat |
A matrix of individual state-space grid extents returned from
|
s.st |
A matrix of starting activity center coordinates. This is
returned from |
site |
Either |
hab_mask |
A matrix or arary output from |
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').
X
Rescaled trap coordinates
ext_mat
Rescaled matrix of individual state-space grid extents.
s.st
A matrix of rescaled starting activity center coordinates.
Daniel Eacker
mask_polygon
, mask_raster
## Not run: # 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) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.