suit.change {divraster} | R Documentation |
Species Suitability Change Between Climate Scenarios
Description
Compares two SpatRaster
objects, each containing species presence-absence data
for multiple species under different climate scenarios (e.g., baseline vs. future).
It calculates and encodes the change in habitat suitability (gain, loss, unchanged, unsuitable)
for each species in each raster cell.
Usage
suit.change(r1, r2, filename = "")
Arguments
r1 |
A |
r2 |
A |
filename |
Character string. Optional path and filename to save the resulting |
Details
This function processes each species layer independently. It's crucial that
both input SpatRaster
s (r1
and r2
) have the same extent, resolution, and
the same number of layers, with corresponding layers representing the same species.
The function expects binary (0 or 1) presence-absence data.
Value
A SpatRaster
object with multiple layers, where each layer corresponds to a species
from the input SpatRasters. Cell values are encoded as follows:
1 = Gain: Species absent in r1 (baseline) becomes present in r2 (future).
2 = Loss: Species present in r1 (baseline) becomes absent in r2 (future).
3 = Unchanged (Presence): Species present in both r1 and r2.
4 = Unsuitable (Both): Species absent in both r1 and r2.
The dimensions, resolution, and layer names of the output raster will match those of the input
r1 and r2.
Examples
library(terra)
# Load example rasters for baseline and future climate scenarios
r1 <- terra::rast(system.file("extdata", "ref.tif", package = "divraster"))
r2 <- terra::rast(system.file("extdata", "fut.tif", package = "divraster"))
# Calculate suitability change
change_map <- suit.change(r1, r2)
change_map