| adj_mat | R Documentation |
Creates an adjacency matrix of an area of interest. This could be the accessible area (M) of a species or any geographic region of interest.
adj_mat(modelsparse, ngbs = 1, eigen_sys = FALSE, which_eigs = 1)
modelsparse |
A setA object returned by the function
|
ngbs |
Numeric. Number of neighbors (see details). |
eigen_sys |
Logical. If TRUE the eigen analyses of the adjacency matrix will be returned. |
which_eigs |
Numeric. Which eigen value and eigen vector will be returned. |
The model is a raster object of the area where the dispersal process will occur.
The function creates an adjacency matrix where cells are considered connected based on:
The specified neighborhood size ('ngbs')
The spatial resolution of the input raster
Only non-NA cells in the original model
When 'eigen_sys = TRUE', the function performs spectral decomposition using eigs,
which is particularly useful for:
Analyzing network connectivity properties
Identifying clusters or communities in the landscape
Modeling dispersal processes using spectral graph theory
The number of neighbors depends on the dispersal abilities of the species and the spatial resolution of the niche model; for example, a species's with big dispersal abilities will move throughout more than 1 km^2 per day, so the idea is to give an approximate number of moving neighbors (pixels) per unit of time.
Returns an object of class setM with 7 slots.
The first contains the adjacency matrix. A n x n sparse matrix (n=number of
non-NA cells of the niche model) where connected cells are represented by 1.
The second slot has the adjacency list. It is a list of matrices with four
columns (FromRasCell -from cell ID of the raster-, -to cell ID of the
raster-, -from non-NA cell-, -to non-NA cell-). Other slots contain
information about initial coordinates where dispersal occurs
(initial_points), number of cells used to define the neighborhood (ngbs),
non-NA coordinates (coordinates), and a matrix of eigen vectors (eigen_vec).
Luis Osorio-Olvera & Jorge Soberón
SoberonOsoriobamm.
model2sparse for creating the input 'setA' object
setM for the output class structure
eigs for the eigen decomposition implementation
For more information about see adjacency matrices in the context of the theory of area of distribution (Soberon and Osorio-Olvera, 2022).
x_coord <- c(-106.5699, -111.3737,-113.9332,
-110.8913, -106.4262, -106.5699)
y_coord <- c(16.62661, 17.72373, 19.87618,
22.50763, 21.37728, 16.62661)
xy <- cbind(x_coord, y_coord)
p <- sp::Polygon(xy)
ps <- sp::Polygons(list(p),1)
sps <- sp::SpatialPolygons(list(ps))
mx_grid <- bamm::shape2Grid(sps,resolution = 0.25,ones = TRUE)
mx_sparse <- bamm::model2sparse(model=mx_grid, threshold = 0.1)
adj_mx <- bamm::adj_mat(modelsparse=mx_sparse,
ngbs=1,eigen_sys=TRUE,which_eigs=1)
print(adj_mx)
mx_grid_eigen <- mx_grid
mx_grid_eigen[mx_sparse@cellIDs] <- adj_mx@eigen_vec
raster::plot(mx_grid_eigen)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.