prepare_base_PAM {biosurvey}R Documentation

Presence-absence matrix (PAM) linked to a spatial grid


Prepares a presence-absence matrix (PAM) in which all sites of interest (rows) will have a value for presence or absence of a species of interest (columns). Initial points of interest will be represented by an ID, and longitude and latitude coordinates. The PAM will be linked to a spatial grid.


prepare_base_PAM(data, format = NULL, master_matrix, cell_size,
                 complete_cover = TRUE, clip_grid = FALSE,
                 indices = "basic", parallel = FALSE, n_cores = NULL,
                 verbose = TRUE)



species geographic ranges to be used to create a presence-absence matrix (PAM). This argument can be: character, data.frame, RasterStack, RasterBrick, list, SpatialPolygonsDataFrame, or SpatialPointsDataFrame. See details for a description of the characteristics of data for each option.


(character) if data is of class character, available options are: "shp", "gpkg", "geojson", "GTiff", and "ascii".


object of class "master_matrix" or "master_selection". See details.


(numeric) resolution for grid (single number or vector of two numbers) in kilometers (km).


(logical) whether or not to include cells of grid partially overlapped with the geographic region of interest contained in master_matrix. Default = TRUE.


(logical) whether to clip the spatial grid using the region of interest. Clipping improves visualization but depending on how complex the region of interest is it could take time to perform this task.


(character) code for indices to be calculated. Basic indices are calculated all the time, other indices need to be specified. Options are: "all", "basic, "AB", "BW", "BL", "SCSC", "SCSR", "DF", "CC", "WRN", "SRC", "CMSC", and "CMSR". Default = "basic". See details.


(logical) whether to perform analyses in parallel. Default = FALSE. Not used if data is of class data.frame, RasterStack, or RasterBrick.


(numeric) number of cores to be used when parallel = TRUE. The default, NULL, uses available cores - 1.


(logical) whether or not to print messages about the process. Default = TRUE.


Objects of class "master_matrix" or "master_selection" can be obtained from functions prepare_master_matrix, random_selection, uniformG_selection, uniformE_selection, or uniformEG_selection. The element region or mask if this last is not NULL is used to prepare the spatial grid.

Geographic projection of objects or coordinates involved must be WGS84 (EPSG:4326).

Description of objects to be used as data:

A list of codes and indices that can be calculated is described below. For further details on the way calculations are performed and the meaning of the indices see Soberon and Cavner (2015) doi: 10.17161/bi.v10i0.4801.

Code Index Calculation
RI Richness Basic
RA Range Basic
RIN Richness normalized Basic
RAN Range normalized Basic
AB Additive Beta Needs to be defined
BW Beta Whittaker Needs to be defined
BL Beta Legendre Needs to be defined and DF
SCSC Schluter covariance sites-composition Needs to be defined and CMSC
SCSR Schluter covariance species-ranges Needs to be defined and CMSR
DF Dispersion field Needs to be defined
SCC Shared community composition Needs to be defined
WRN Wright-Reeves nestedness Needs to be defined, BW, and DF
SRC Stone-Roberts C-score Needs to be defined and DF
CMSC Covariance matrix sites-composition Needs to be defined, DF, and BW
CMSR Covariance matrix species-ranges Needs to be defined, SCC, and BW
MCC Mean composition covariance Calculated with CMSC
MRC Mean range covariance Calculated with CMSR


A presence-absence matrix (PAM) of class base_PAM for the region of interest associated with a SpatialPolygonsDataFrame, as in a grid of cell_size resolution. Each grid cell is related to a specific ID and longitude and latitude coordinates. Presence (1) and absence (0) values for each species in every cell of the PAM are included as apart of the data.frame of the SpatialPolygonsDataFrame. PAM indices is returned with the basic indices of biodiversity as default, but can be changed using the argument indices.

See Also



# Data
data("m_matrix", package = "biosurvey")
data("species_data", package = "biosurvey")

# Create base_PAM
b_pam <- prepare_base_PAM(data = species_data, master_matrix = m_matrix,
                          cell_size = 100)
summary(b_pam$PAM@data[, 1:6])

[Package biosurvey version 0.1.1 Index]