Aggregation index (Aggregation metric)

## Arguments

- landscape
A categorical raster object: SpatRaster; Raster* Layer, Stack, Brick; stars or a list of SpatRasters

- directions
The number of directions in which patches should be connected: 4 (rook's case) or 8 (queen's case).

## Details

$$AI = \Bigg[\sum\limits_{i=1}^m \Big( \frac{g_{ii}}{max-g_{ii}} \Big) P_{i} \Bigg](100) $$

where \(g_{ii}\) is the number of like adjacencies based on the single-count method and \(max-g_{ii}\) is the classwise maximum number of like adjacencies of class i and \(P_{i}\) the proportion of landscape compromised of class i.

AI is an 'Aggregation metric'. It equals the number of like adjacencies divided by the theoretical maximum possible number of like adjacencies for that class summed over each class for the entire landscape. The metric is based on the adjacency matrix and the single-count method.

## References

McGarigal K., SA Cushman, and E Ene. 2023. FRAGSTATS v4: Spatial Pattern Analysis Program for Categorical Maps. Computer software program produced by the authors; available at the following web site: https://www.fragstats.org

He, H. S., DeZonia, B. E., & Mladenoff, D. J. 2000. An aggregation index (AI) to quantify spatial patterns of landscapes. Landscape ecology, 15(7), 591-601.