
Calculate feature representation within an area
Source:R/feature_representation.R
feature_representation.RdThis function calculates the representation of each feature across raster cells, and can optionally summarize results within a specified area.
Arguments
- feature_layers
A
terra::SpatRasterwith one or more layers representing feature distributions (e.g., species distributions, habitat suitability).- area_mask
Optional. A
terra::SpatRasterorterra::SpatVectordefining the analysis area. If a raster is provided, it should follow the Zonation analysis area mask convention, where cells with value 1 represent the area of interest and cells with value 0 orNAare excluded. If aSpatVectoris provided, it will be rasterized to match the resolution and extent offeature_layers.
Value
A list with two elements:
- representation_layers
A
terra::SpatRasterwhere each layer contains the fractional representation of the corresponding feature across the landscape. Each cell value represents the proportion of the global total representation of that feature occurring in that cell.- representation_in_area
A named numeric vector containing the representation of each feature within the specified
area_mask. If no area is provided, this element returnsNULL.
See also
Other postprocessing:
cost_summary(),
coverage_distribution(),
feature_curves(),
priority_map(),
rank_similarity(),
summary_curves()
Examples
r <- terra::rast(nrows = 10, ncols = 10)
f1 <- terra::setValues(r, runif(terra::ncell(r)))
f2 <- terra::setValues(r, runif(terra::ncell(r)))
features <- c(f1, f2)
names(features) <- c("feature_1", "feature_2")
mask <- r
terra::values(mask) <- sample(c(0,1), terra::ncell(mask), replace = TRUE)
result <- feature_representation(features, mask)
result$representation_in_area
#> feature_1 feature_2
#> 0.4622109 0.4387114