Generate Random Category Landscape

Share:

Description

A function to generate a multidimensional landscape with each cell randomly assigned a category number such that the total ratio of category types accross the landscape corresponds to a proportion vector input.

Usage

1
PercolationMap(DimExtents, Props, Cat.Labels = 1:length(Props))

Arguments

DimExtents

An integer vector with the length of the desired output in each dimension. length(DimExtents) gives the number of dimensions in the output.

Props

An integer vector with a each element containing the number of cells to assign to each category type. length(Props) gives the number of categories to assign. Note that prod(DimExtents) must equal to or less than sum(Props) otherwise an error is displayed. If prod(DimExtents) is less than sum(Props) then all remaining cells are assigned to an NA category.

Cat.Labels

A vector of category labels to attach to each of the assigned category types. If length(Cat.Labels) is less than length(Props) then Cat.Labels is recycled.

Value

A vector of length prod(DimExtents) and with a dimensional extent attribute set to DimExtents. Each element contains the corresponding category label given in Cat.Labels to the assigned category type.

Author(s)

Joseph Chipperfield <joechip90@googlemail.com>

References

Gardner, R. H., Milne, B. T., Turner, M. G. and O'Neill, R. V. (1987) Neutral models for the analysis of broad-scale landscape pattern. Landscape Ecology, 1, 19-28.

With, K. A. (1997) The application of neutral landscape models in conservation biology. Conservation Biology, 11, 1069-1080.

With, K. A. and King A. W. (1997) The use and misuse of neutral landscapes models in ecology. Oikos, 79, 219-229.

See Also

HierarchicalCurdling SpectralSynthesis

Examples

1
2
3
4
5
6
7
8
9
# Create a 100 x 100 landscape with 3000 "grass" cells, 2000 "sand" cells, and
# 5000 "bog" cells
dims.in <- rep(100,2)				# Dimension extent
props <- c(3000, 2000, 5000)			# Proportions of each habitat type
cat.labels <- c("grass", "sand", "bog")		# Category labels
output.map <- PercolationMap(dims.in, props, cat.labels)
# Code the outputs into values for display
coded.map <- ifelse(output.map == "grass", 1, ifelse(output.map == "sand", 2, 3))
image(coded.map, col = c("green", "yellow", "brown"))