Skip to contents

This function calculates the area of suitable habitat from a binary species raster (r1_multi) and, optionally, the area of overlap with a second raster (r2). The second raster r2 can be continuous (requiring a threshold) or already binary. The calculation can be performed for the entire raster extent ("total") or be separated by categories defined in a polygon vector (polys).

Usage

area.calc.flex(
  r1_multi,
  r2 = NULL,
  polys = NULL,
  threshold,
  category_col = NULL,
  cellSz = NULL
)

Arguments

r1_multi

A SpatRaster with multiple layers (species), with values of 1 (presence) and 0 (absence).

r2

A single-layer SpatRaster. Can be continuous or binary (0/1). Optional.

polys

A SpatVector of polygons with categories. Optional.

threshold

A numeric threshold to binarize r2. Only required if r2 is continuous.

category_col

The name of the column in polys with the categories. Required if polys is used.

cellSz

A pre-calculated SpatRaster of cell sizes in km^2. If NULL (default), it will be calculated automatically. Providing this can increase efficiency.

Value

A standard R data.frame with the calculated areas in square kilometers.