NeighbRasterStack {lulcc} | R Documentation |
Create a NeighbRasterStack object
Description
Methods to calculate neighbourhood values for cells in raster maps using
raster::focal
. By default the fraction of non-NA cells
within the moving window (i.e. the size of the weights matrix) devoted to each
land use category is calculated. This behaviour can be changed by altering the
weights matrix or providing an alternative function. The resulting object can
be used as the basis of neighbourhood decision rules.
Usage
NeighbRasterStack(x, weights, neighb, ...)
## S4 method for signature 'RasterLayer,list,ANY'
NeighbRasterStack(x, weights, neighb,
categories, fun = mean, ...)
## S4 method for signature 'RasterLayer,matrix,ANY'
NeighbRasterStack(x, weights, neighb,
categories, fun = mean, ...)
## S4 method for signature 'RasterLayer,ANY,NeighbRasterStack'
NeighbRasterStack(x, weights,
neighb)
Arguments
x |
RasterLayer containing categorical data |
weights |
list containing a matrix of weights (the |
neighb |
NeighbRasterStack object. Only used if |
... |
additional arguments to |
categories |
numeric vector containing land use categories for which neighbourhood values should be calculated |
fun |
function. Input argument to |
Value
A NeighbRasterStack object.
See Also
NeighbRasterStack-class
, allowNeighb
,
raster::focal
Examples
## Plum Island Ecosystems
## observed data
obs <- ObsLulcRasterStack(x=pie,
pattern="lu",
categories=c(1,2,3),
labels=c("forest","built","other"),
t=c(0,6,14))
## create a NeighbRasterStack object for 1985 land use map
w1 <- matrix(data=1, nrow=3, ncol=3, byrow=TRUE)
w2 <- w1
w3 <- w1
nb1 <- NeighbRasterStack(x=obs[[1]],
categories=c(1,2,3),
weights=list(w1,w2,w3))
## update nb2 for 1991
nb2 <- NeighbRasterStack(x=obs[[2]],
neighb=nb1)
## plot neighbourhood map for forest
plot(nb2[[1]])