Description Usage Arguments Details References See Also
Morphologically modify a raster
1 2 |
obj |
[ |
kernel |
[ |
blend |
[ |
merge |
[ |
rotate |
[ |
strictKernel |
[ |
background |
[ |
The morphC function (internal) is the basis of many modify
operations in rasterTools
and rMorph
exposes a fully
functional interface of this C++ function. The morphC function iteratively
goes through each pixel of a raster (obj
) and compares the kernel
with the raster at that location. The result of this comparison depends on
the arguments blend
and merge
:
First, all
values in raster that are covered by the kernel (which may be larger than
one pixel) are "cut out" and summarised pairwise with kernel
(i.e.
they are blended) by the function defined in blend
(e.g.
"+"), leaving as many values as cells in kernel
.
Then these
values are summarised into a single value (i.e. they are merged) by
the function defined in merge
(e.g. "mean") and the resulting value
is assigned in the current location in the raster.
The following functions are defined for blend
:
identity: the value of obj
where kernel
is not NA.
equal: the value 1 where obj
and kernel
are equal, otherwise
the value 0.
lower: the values of obj
that are lower than
kernel
, otherwise 0.
greater: the values of obj
that
are greater than kernel
, otherwise 0.
plus: the values of
obj
added to the values of kernel
.
minus: the values of
kernel
subtracted from the values of obj
.
product: the
product of the values of obj
and kernel
.
The following
functions are defined for merge
:
min: the minimum value.
max: the maximum value.
all: the value 1 if all non-NA values are not 0, otherwise 0.
any: the value 1 if any of the non-NA values are not 0, otherwise 0.
sum: the sum of all non-NA values.
mean: the mean of all non-NA values.
median: the median of all non-NA values.
sd: the standard deviation of all non-NA values.
cv: the coefficient of variation of all non-NA values.
sumNa: if the sum of all values is greater than 0 than this sum, otherwise NA.
Credit for the original idea/architecture of the C++ part of this function goes to Jon Clayden (R::mmand). The functionality has been slightly extended here.
Other operators to morphologically modify a raster: rDilate
,
rErode
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.