departure: Climatic departure

departureR Documentation

Climatic departure

Description

This function quantifies the amount of change between historical and future climate conditions inside a species' habitat.

Usage

departure(x, y, s.dat, ...)

## S4 method for signature 'GLdeparture,missing,cnfa'
departure(x, s.dat, filename = "", ...)

## S4 method for signature 'GLdeparture,missing,Spatial'
departure(x, s.dat, field, fun = "last", filename = "", ...)

## S4 method for signature 'Raster,Raster,cnfa'
departure(
  x,
  y,
  s.dat,
  center = TRUE,
  scale = TRUE,
  filename = "",
  progress = FALSE,
  parallel = FALSE,
  n = 1,
  ...
)

## S4 method for signature 'Raster,Raster,Spatial'
departure(
  x,
  y,
  s.dat,
  center = TRUE,
  scale = TRUE,
  filename = "",
  progress = FALSE,
  parallel = FALSE,
  n = 1,
  ...
)

Arguments

x

Raster* object, typically a brick or stack of historical climate raster layers or a brick of absolute differences (see Details)

y

Raster* object, future climate values with the same layers as x

s.dat

SpatialPolygons*, sf, or cnfa object detailing species presence

...

Additional arguments for clusterR

filename

character. Optional filename to save the Raster* output to file. If this is not provided, a temporary file will be created for large x

field

field of s.dat that specifies presence. This is equivalent to the field argument of raster::rasterize. Options are 'first', 'last' (default), and 'count'

fun

function or character. Determines what values to assign to cells with multiple spatial features, similar to the fun argument in rasterize

center

logical. If TRUE then the values of x and y will be centered on the means of the historical climate data

scale

logical. If TRUE then the values of x and y will be scaled by the sds of the historical climate data

progress

logical. If TRUE, messages and progress bar will be printed

parallel

logical. If TRUE then multiple cores are utilized

n

numeric. Optional number of CPU cores to utilize for parallel processing

Details

For comparisons of multiple species in the same study area, it is much more efficient to first construct a Raster* object of absolute differences between the historical and future values, so that the differences do not need to be recalculated for each species. This can be achieved with by passing x and y to the difRaster function, and then passing the results to the departure function.

When only one Raster* object is supplied, it is assumed that x is a Raster* object containing the absolute differences of a historical and future dataset.

Value

Returns an S4 object of class departure with the following slots:

call

Original function call

df

Departure factor. Vector of length p that describes the amount of departure between future and historical conditions for each climate variable

departure

Magnitude of the departure factor

g.cov

p x p historical global covariance matrix

ras

RasterBrick of climate departures, with p layers

weights

Raster layer of weights used for departure calculation

References

Rinnan, D. Scott and Lawler, Joshua. Climate-niche factor analysis: a spatial approach to quantifying species vulnerability to climate change. Ecography (2019): <doi:10.1111/ecog.03937>.

Examples

dep1 <- departure(x = climdat.hist, y = climdat.fut, s.dat = ABPR, field = "CODE")

# using difRaster as an initial step
# for multi-species comparison

gld <- GLdeparture(x = climdat.hist, y = climdat.fut)
dep2 <- departure(x = gld, s.dat = ABPR, field = "CODE")

# same results either way
all.equal(dep1@df, dep2@df)


rinnan/CENFA documentation built on July 19, 2023, 12:58 p.m.