Learn R Programming

secr (version 3.0.1)

randomHabitat: Random Landscape

Description

The Modified Random Cluster algorithm of Saura and Martinez-Millan (2000) is used to generate a mask object representing patches of contiguous `habitat' cells (pixels) within a `non-habitat' matrix (`non-habitat' cells are optionally dropped). Spatial autocorrelation (fragmentation) of habitat patches is controlled via the parameter `p'. `A' is the expected proportion of `habitat' cells.

Usage

randomHabitat(mask, p = 0.5, A = 0.5, directions = 4, minpatch = 1,
drop = TRUE, covname = "habitat", plt = FALSE)

Arguments

mask
secr mask object to use as template
p
parameter to control fragmentation
A
parameter for expected proportion of habitat
directions
integer code for adjacency (rook's move 4 or queen's move 8)
minpatch
integer minimum size of patch
drop
logical for whether to drop non-habitat cells
covname
character name of covariate when drop = FALSE
plt
logical for whether intermediate stages should be plotted

Value

An object of class `mask'. By default (drop = TRUE) this has fewer rows (points) than the input mask.

Details

Habitat is simulated within the region defined by the cells of mask. The region may be non-rectangular.

The algorithm comprises stages A-D:

A. Randomly select proportion p of cells from the input mask

B. Cluster selected cells with any immediate neighbours as defined by directions

C. Assign clusters to `non-habitat' (probability 1--A) and `habitat' (probability A)

D. Cells not in any cluster from (B) receive the habitat class of the majority of the <=8 adjacent cells assigned in (C), if there are any; otherwise they are assigned at random (with probabilities 1--A, A).

Fragmentation declines, and cluster size increases, as p increases up to the `percolation threshold' which is about 0.59 in the default case (Saura and Martinez-Millan 2000 p.664).

If minpatch > 1 then habitat patches of less than minpatch cells are converted to non-habitat, and vice versa. This is likely to cause the proportion of habitat to deviate from A.

If drop = FALSE a binary-valued (0/1) covariate with the requested name is included in the output mask, which has the same extent as the input. Otherwise, non-habitat cells are dropped and no covariate is added.

References

Hijmans, R. J. and van Etten, J. (2011) raster: Geographic analysis and modeling with raster data. R package version 1.9-33. https://CRAN.R-project.org/package=raster.

Saura, S. and Martinez-Millan, J. (2000) Landscape patterns simulation with a modified random clusters method. Landscape Ecology, 15, 661--678.

See Also

mask, make.mask, sim.popn

Examples

Run this code

## Not run: ------------------------------------
# 
# tempmask <- make.mask(nx = 100, ny = 100, spacing = 20)
# mrcmask <- randomHabitat(tempmask, p = 0.4, A = 0.4)
# plot(mrcmask, dots = FALSE, col = "green")
# pop <- sim.popn(10, mrcmask, model2D = "IHP")
# plot(pop, add = TRUE)
# 
# ## plot intermediate steps A, C, D
# par(mfrow = c(1,3))
# mrcmask <- randomHabitat(tempmask, p = 0.4, A = 0.4, plt = TRUE)
# par(mfrow = c(1,1))    ## reset to default
# 
# ## keep non-habitat cells
# mrcmask <- randomHabitat(tempmask, p = 0.4, A = 0.4, drop = FALSE)
# plot(mrcmask, covariate = "habitat", dots = FALSE,
#     col = c("grey","green"), breaks = 2)
# 
# ## effect of purging small patches
# opar <- par(mfrow=c(1,2))
# mrcmask <- randomHabitat(tempmask, p = 0.4, A = 0.4, minpatch = 1)
# plot(mrcmask, dots = FALSE, col  ="green")
# mrcmask <- randomHabitat(tempmask, p = 0.4, A = 0.4, minpatch = 5)
# plot(mrcmask, dots = FALSE, col  ="green")
# par(opar)
## ---------------------------------------------

Run the code above in your browser using DataLab