makeClass {landscapeR} | R Documentation |
Create a class of patches.
Description
Create a class of patches.
Usage
makeClass(context, npatch, size, pts = NULL, bgr = 0, edge = FALSE,
rast = TRUE, val = 1)
Arguments
context |
Raster object, a raster of an empty landscape or a mask, indicating where the patch cannot be generated (see |
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 or matrix. The seed point location around which the patches are built (random points are given by default). It can be an integer, as indexes of the cells in the raster, or a two columns matrix indicating x and y coordinates. |
bgr |
integer. A single 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 |
Details
The patches created can be contiguous, therefore resembling a single patch with size
equal to the sum of contiguous cells. The patches are created starting from the seed points (if provided) and iteratively sampling randomly neighbouring cells at the edge of the patch, according to von Neumann neighbourhood (four cells, aka Rook case).
There is a tolerance of +/- 3 cells from the patch size declared in size
argument.
Value
A RasterLayer object, or a vector of cell numbers if rast=FALSE
.
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)