Function for calculating the classic pixel-adjacency contagion landscape metric from a binary map (O'Neill, 1988).
contagpixelgrid(xi, obswin, normalise = FALSE) adjacency(xi, obswin = NULL)
A raster binary map (as an
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
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 || Second pixel not in
First pixel in ||-||-|
First pixel not in ||-||-|
The computed pixel-adjacency contagion value. If
TRUE then the value will be between 0 and 1. Otherwise the value will be negative.
contagpixelgrid: Pixel-adjacency contagion landscape metric of a binary map.
adjacency: Calculates the adjacency matrix used in the pixel contagion
Will fail if map is either all foreground or all background.
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.
xi <- heather$coarse obswin <- owin(xrange = c(0,7),yrange=c(0,16)) adjmat <- adjacency(xi,obswin) pixeladjcontagion <- contagpixelgrid(xi,obswin)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.