secr (version 4.6.6)

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.

randomDensity is a wrapper for randomHabitat that may be used as input to sim.popn.

Usage

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

randomDensity(mask, parm)

Value

For randomHabitat --

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

The attribute ``type'' is a character string formed from paste('MRC p=',p, ' A=',A, sep='').

The RNG seed is stored as attribute `seed' (see secrRNG).

For randomDensity --

A vector of cell-specific densities.

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

seed

either NULL or an integer that will be used in a call to set.seed

parm

list of arguments for randomHabitat, with added argument D

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.

The argument `parm' for randomDensity is a list with average density D and an optional subset of named values to override the defaults (p = 0.5, A = 0.5, directions = 4, minpatch = 1, plt = FALSE, seed = NULL). `rescale' is a further optional component of `parm'; if `rescale = TRUE' then the pixel-specific densities are adjusted upwards by the factor 1/A to maintain the same expected number of activity centres as if the nominal density applied throughout. Arguments `mask' and `drop' of randomHabitat are substituted automatically.

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

if (FALSE) {

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)

# OR
plot(sim.popn(D = randomDensity, core = tempmask, model2D = "IHP",
    details = list(D = 10, p = 0.4, A = 0.4, plt = TRUE)), 
    add = TRUE, frame = FALSE)

## plot intermediate steps A, C, D
opar <- par(mfrow = c(1,3))
mrcmask <- randomHabitat(tempmask, p = 0.4, A = 0.4, plt = TRUE)
par(opar) 

## 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