# contagpixelgrid: Pixel Adjacency Contagion In lacunaritycovariance: Gliding Box Lacunarity and Other Metrics for 2D Random Closed Sets

 contagpixelgrid R Documentation

### Description

Function for calculating the classic pixel-adjacency contagion landscape metric from a binary map (O'Neill, 1988).

### Usage

contagpixelgrid(xi, obswin, normalise = FALSE)

### Arguments

 xi A raster binary map (as an im object) or as a foreground set (as an owin object). In the latter case the observation window, obswin, must be supplied. See lacunaritycovariance-package for details. If xi is an owin object it must be of mask type. obswin If xi is an owin object then obswin is an owin object that specifies the observation window. normalise If TRUE will divide result by 2 ln(2) and add 1 to make contagion between 0 and 1 for all binary maps.

### Details

The unnormalised contagion landscape metric of categorical map is defined as

∑_i ∑_j Qij ln(Qij),

where Qij is the probability of randomly selected adjacent pixels being in class i and class j respectively, and m is the number of classes.

Here m = 2 as xi is a binary map and we have defined 'adjacent' pixels using the 4-neighbourhood regime.

Contagion is calculated from an adjacency matrix created using the function adjacency. The adjacency matrix is a 2 by 2 table containing the number of pairs of neighbouring pixels (where order matters) such that:

 Second pixel in xi Second pixel not in xi First pixel in xi - - First pixel not in xi - -

### Value

The computed pixel-adjacency contagion value. If normalise is TRUE then the value will be between 0 and 1. Otherwise the value will be negative.

### Functions

• contagpixelgrid: Pixel-adjacency contagion landscape metric of a binary map.

### Warning

Will fail if map is either all foreground or all background.

### References

O'Neill, R.V., Krummel, J.R., Gardner, R.H., Sugihara, G., Jackson, B., DeAngelis, D.L., et al. (1988) Indices of landscape pattern. Landscape Ecology, 1, 153-162.

### Examples

xi <- heather\$coarse
obswin <- owin(xrange = c(0,7),yrange=c(0,16))