Skip to contents

Connected components of equal-class cells (4 or 8 neighbours), numbered from 1 by class (ascending) and, within a class, in column-major order of their first cell, as landscapemetrics::get_patches.

Usage

LabelPatches(landscape, directions = 8)

Arguments

landscape

Integer matrix of classes (NA allowed).

directions

4 or 8.

Value

List with labels (matrix, 0 for NA) and patch_class.

Examples

LabelPatches(rbind(c(1, 1, 2), c(2, 1, 2)), directions = 4)$labels
#>      [,1] [,2] [,3]
#> [1,]    1    1    3
#> [2,]    2    1    3