rasterLocalCategoricalModes: Local categorical modes for an in memory raster image

Description Usage Arguments Details Value Examples

View source: R/rasterLocalCategoricalModes.R

Description

rasterLocalCategoricalModes finds the most popular category within the weighted neighborhood of W.

Usage

1

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.

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.

Value

An in memory raster image by most popular categories.

Examples

1
2
3
r <- raster::raster( matrix(runif(81),9,9)) 
W <- matrix(1,3,3)
modeR <- rasterLocalCategoricalModes(r,W)

rasterKernelEstimates documentation built on Sept. 21, 2021, 9:07 a.m.