View source: R/createSpeciesRaster.R
createSpeciesRaster | R Documentation |
This function takes a rasterStack and generates both a richness
raster and an associated list of species per cell, creating an object of
class speciesRaster
.
createSpeciesRaster(ranges, rasterTemplate = NULL, verbose = FALSE)
ranges |
Either a RasterStack, RasterBrick, or species by cell matrix. Any non-NA values in rasters are considered presences. |
rasterTemplate |
If input is a species x cell matrix, then a rasterTemplate must be provided, where the number of cells = the number of columns in the matrix. Cells with a value of 1 will be processed, cells with a value of 0 will be . Therefore, all cells must have a value of 0/1. |
verbose |
Primarily intended for debugging, print progress to the console. |
This function generates an object of class speciesRaster
, which is a
list containing the following elements:
raster:
A raster representing counts of species per cell.
speciesList:
A list of species found in each cell.
geogSpecies:
a vector of unique species in all cells.
cellCount:
a vector of counts of presence cells for each species.
data:
An empty spot that morphological data can be added to.
phylo:
An empty spot that a phylogeny can be added to.
If input is a RasterStack, then all parameters are taken from that, such as resolution, extent and projection. Any non-NA and non-zero cell is considered a presence. This function expects that all input rasters in the rasterStack have presence values (i.e., at least 1 non-NA value). If any rasters have exclusively NA cells, then the function will stop with a warning, and the output will be the index in the rasterStack of those rasters.
an object of class speciesRaster
.
Pascal Title
library(raster) library(sf) # example dataset: a list of 24 chipmunk distributions as polygons head(tamiasPolyList) # convert polygon ranges to raster ranges <- rasterStackFromPolyList(tamiasPolyList, resolution = 20000) spRas <- createSpeciesRaster(ranges = ranges) spRas
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.