Last data update: 2014.03.03

R: Create a class of patches.
makeClassR Documentation

Create a class of patches.

Description

Create a class of patches.

Usage

makeClass(context, npatch, size, pts = sample.int(length(context), npatch),
  bgr = 0, edge = FALSE, rast = TRUE, val = 1)

Arguments

context

Raster object or matrix, an empty landscape raster or a mask indicating where the patch cannot be generated (see bgr below).

npatch

number of patches per class

size

integer. The size of patches, as number of raster cells. A single integer can be provided, in which case all patches will have that size.

pts

integer, the seed point locations around which the patches are built (random points are given by default)

bgr

integer. Value of background cells, where a patch can be generated (default is zero). Cells/classes which cannot be changed must have a different value.

edge

logical. Should the vector of edge cells of the patch be returned?

rast

logical. If TRUE returns a Raster object, otherwise a vector of cell numbers where the patch occurs

val

integer. The value to be assigned to patch cells, when rast=TRUE

Details

The patches created can be contiguous, therefore resembling a single patch with size equal to the sum of contiguous cells.

Value

A vector of matrix cell numbers, or an raster object if rast=TRUE.

Examples

library(raster)

m = matrix(0, 33, 33)
r = raster(m, xmn=0, xmx=10, ymn=0, ymx=10)
num = 5
size = 15
rr = makeClass(r, num, size)
plot(rr)

## Create a class of three patches of given size at three corners of the spatial context
size = c(10, 50, 200)
pts = c(1, 33, 1089)
rr = makeClass(r, 3, size, pts)
plot(rr)

Results