rasterLocalCategoricalModes: Local categorical modes for an in memory raster image
Description
rasterLocalCategoricalModes finds the most popular category within the
weighted neighborhood of W.
Usage
rasterLocalCategoricalModes(r, W)
Arguments
r
An in memory raster image. Pixels should be whole numbers or NA.
Pixels with non-whole number values will be coerced into whole numbers.
W
A matrix of weights. The modal kernel will be applied to each
pixel in r. Dimensions must be non-zero and odd.
Value
An in memory raster image by most popular categories.
Details
A spatial neighborhood is calculated for each pixel in r.
The spatial neighborhood for each pixel is defined by the weight matrix
W, where the center of the odd dimensioned matrix W is identified
with the target pixel. The target pixel value is replaced with the most
popular value within the neighborhood weighted by W. Ties are
handled by randomly by uniformly selecting a category amongst the tied
categories. Only non-missing or neighbors with non-zero weights are used
in the calculation.