patchsizes: Get patch sizes.

Description Usage Arguments Value See Also Examples

View source: R/label.R

Description

Get the distribution of patch sizes of a logical matrix

Usage

1
2
patchsizes(mat, merge = FALSE, nbmask = matrix(c(0, 1, 0, 1, 0, 1, 0, 1, 0),
  ncol = 3), wrap = FALSE)

Arguments

mat

A logical matrix or a list of these matrices.

merge

Controls whether the obtained patch size distributions are to be pooled together if mat is a list of matrices.

nbmask

a square matrix with an odd number of lines and columns that describes which neighbors are to be considered around a cell. Default is 4-way neighborhood (the neighborhood of a cell comprises the cell above, below, on the right and on the left of the target cell).

wrap

Whether to wrap around lattice boundaries ('TRUE'/'FALSE'), effectively using periodic boundaries.

Value

If mat is a logical matrix, then the function returns a vector of patch sizes. If mat is a list of logical matrices, then it returns a list of vectors of patch sizes: this list is flattened if merge is TRUE.

See Also

label

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
data(forestgap)
patchsizes(forestgap[[5]]) # Use a single matrix

# Compute the average patch size of each matrix
list_patches <- patchsizes(forestgap) # get the patch size for each matrix
print( sapply(list_patches, mean)) # print the average patch size 

# Example with 8-way neighborhood
nbmask8 <- matrix(c(1,1,1,
                    1,0,1,
                    1,1,1), ncol = 3)
patchsizes(forestgap[[5]], nbmask = nbmask8)

spatialwarnings documentation built on May 2, 2019, 5:16 p.m.