assignRefugiaFromAbundanceRaster: Rescale carrying capacity rasters and assign refugia

View source: R/assignRefugiaFromAbundanceRaster.r

assignRefugiaFromAbundanceRasterR Documentation

Rescale carrying capacity rasters and assign refugia

Description

This function takes an "abundance" raster (i.e., from an ENM or from a pollen surface) and identifies refugia and starting (relative) abundances for each refugium. It rescales this to the extent and resolution of a "simulation" raster which typically has coarser spatial resolution than the abundance raster. It then generates a vector of cell IDs that correspond to refugia cells and calculates the average relative abundance across refugial cells.

Usage

assignRefugiaFromAbundanceRaster(abund, sim, threshold)

Arguments

abund

Abundance raster.

sim

Simulation raster.

threshold

Numeric. Value at which to threshold the abundance raster. Values that fall above this threshold will be assumed to represent a refuge and values below will be assumed to be outside (i.e., zero abundance).

Details

This function rescales abundances obtained from the abundance raster to a new spatial resolution and extent used for demographic simulations. Since the demographic simulation raster often has cells that are larger than the cells in the abundance raster, it cannot faithfully retain abundances or even all unique refugia identified in the abundance raster. The procedure first thresholds the abundance raster using a user-defined value above which it is assumed a cell was inside a refuge and below which it was assumed to be outside any refuge (zero abundance). A unique "abundId" raster is then created by assigning a unique integer number for each block of contiguous cells (using Moore neighborhood adjacency). This raster is then resampled to the resolution used by the simulation raster. The renumbering is redone so that cells that refugial were not adjacent at the original resolution but are in the new resolution are assigned to the same refuge.
Then, a "simAbund" raster is created with the same extent and resolution as the simulation raster. For each each cell in this raster, the function determines if it contains at least one cell in the "abundId" raster that is assigned to a refuge. The challenge here is that a single "simAbund" cell can contain cells that are assigned to multiple refugia in the "abundId" raster, and that "simAbund" cell can also include cells that have abundances that are assigned to no refugia in the abundance raster. Thus, if we simply assigned abundances to the "simAbund" cell by resampling the abundance raster, we would in some cases be too generous because a single "simAbund" cell can include cells that do not belong to this refuge.
The procedure assigns abundances by first calculating a proportionality scalar where the numerator is the sum of abundances of abundance raster cells in this refugium and in the "simAbund" cell, and the denominator the sum of all abundances of all cells in this "simAbund" cell. The abundance assigned to this "simAbund" cell for this particular refugium is this scalar times the abundance from the resampling of the abundance raster to the extent/resolution of the simulation raster. Thus, abundances assigned to any particular cell in a refuge will be equal to or less than the abundance of the resampled values.
The procedure then assigns each cell an integer number identifying which refugium to belongs to and an abundance corresponding to the given refuge. When cells contain more than one "abundId" refuge cell, the refuge with the greater abundance is assigned to the cell. As a consequence, a refuge that appears in the "abundId" raster could be trimmed in extent or even eliminated if it is only represented by a few cells that have small abundances relative to a more "massive" refugium in the same cell. Also, as a result, it is possible to have distinct refugia in cells that are adjacent to one another when rescaled to the extent/resolution of the simulation raster but are spatially distinct at the scale of the abundance raster.

Value

A list with:

  • 1) A raster stack representing refuge ID numbers and abundances at the simulation resolution and extent

  • 2) a vector of cell numbers for refugial cells at the simulation scale

  • 3) a single numeric value representing mean refugial abundance across cells at the simulation extent.

See Also

getpophist2.cells, calc, resample

Examples

library(raster)
abund <- brick(system.file("extdata/rasters/ccsm_160kmExtent_maxent.tif", package = "holoSimCell"))
abund <- abund[[1]]

load(file=paste0(system.file(package="holoSimCell"),"/extdata/landscapes/",pollenPulls[[1]]$file))
sim <- landscape$sumrast

threshold <- 0.6
refs <- assignRefugiaFromAbundanceRaster(abund, sim, threshold)

cols <- c('red', 'orange', 'yellow', 'green', 'blue', 'purple', 'gray',
	'chartreuse', 'darkgreen', 'cornflowerblue', 'goldenrod3', 'black',
	'steelblue3', 'forestgreen', 'pink', 'cyan', 'darkred')

par(mfrow=c(1, 2))

col <- cols[1:maxValue(refs$sim[['refugiaId']])]
plot(refs$simulationScale[['refugiaId']], col=col, main='refuge ID')
plot(refs$simulationScale[['refugiaAbund']], main='refuge abundance')


stranda/holoSimCell documentation built on Aug. 4, 2023, 1:12 p.m.