knitr::opts_chunk$set( collapse = TRUE, comment = "#>" )
The bam
package is an R package designed to create and operate on large
(tens of millions of cells) matrices regarding to each element of the
$\textbf{BAM}$ scheme, for example, the adjacency matrix (connectivity matrix),
and the niche suitability matrices.
The following vignette presents the basic functions and methods of the bam
package. The package has three main functionalities related to each element of
the BAM scheme.
library(bam)
The package uses sparse matrices to represent those objects which allows it to
optimize computers memory and make important speed ups in computation times by
eliminating operations on zero elements. The basic function of
the package is model2sparse
which converts a raster model to an setA class
model_path <- system.file("extdata/Lepus_californicus_cont.tif", package = "bam") model <- raster::raster(model_path) # binary model model_bin <- model > 0.7 sparse_mod <- bam::model2sparse(model = model_bin)
The slots of the object are
sparse_mod
The function to estimate connecivity between pixels of a given raster is adj_mat
,
(generally is the M area but can be any matrix);
it uses sparse adjancency matrices.
# Adjacency matrix from a niche model adj_mod <- adj_mat(sparse_mod,ngbs=1,eigen_sys = T) adj_mod
The map of the connectivity matrix adj_mod
is
model_eig <- model model_eig[sparse_mod@cellIDs] <- abs(adj_mod@eigen_vec) raster::plot(model_eig)
These are objects that combine SetA and SetM .
Estimates the connectivity suitability and dispersal diagram. It shows the number of geographic clusters as a function of dispersal and suitability.
clustersin <- bam::bam_clusters(model=sparse_mod, ngbs=1,plot_model=FALSE)
The function returns the following slots
clustersin
Lets see the geogrpahic clusters as function of suitability and dispersal
clustersin@interactive_map
raster::plot(clustersin@raster_map)
The CSD diagram is a simple but useful tool to estimate the number of dispersal steps that a species needs to travel per unit time in order to occupay its potential area of distribution. In this example the approximate number of dispersal steps to archive all suitable patches is 30.
csd_plot <- bam::csd_estimate(sparse_mod, dispersal_steps=c(2,4,8,16,32,40))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.