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.
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
r <- raster::raster( matrix(runif(81),9,9))
W <- matrix(1,3,3)
modeR <- rasterLocalCategoricalModes(r,W)
Local moments for an in memory raster image
Description
rasterLocalMoments finds the local moments within the weighted neighborhood
of W.
Usage
rasterLocalMoments(r, WMu, WVar = WMu, moments = 2)
Arguments
r
An in memory raster image.
WMu
A matrix of weights. The mean kernel will be applied to each
pixel in r. Dimensions must be non-zero and odd. Only non-missing
neighbors are used in the mean.
WVar
A matrix of weights. The variance kernel will be applied at each centroid. Dimensions must be non-zero and odd. Only non-missing neighbors are used in the variance. The dimensions of WVar must match WMu.
moments
The number of moments to calculate. The local spatial mean will be calculated when moments=1. The local spatial mean and variance wil be calculated when moments=2. Currently no higher moments are supported.
Value
A list of in memory raster images, one list element for each moment.
Examples
r <- raster::raster( matrix(rnorm(36),6,6))
W <- matrix(1,3,3)
rLocalMoments <- rasterLocalMoments(r,W)
Local quantiles for an in memory raster image
Description
rasterLocalQuantiles finds the quantile within the positive valued neighborhood
of W.
Usage
rasterLocalQuantiles(r, W, q = 50)
Arguments
r
An in memory raster image.
W
A matrix of weights used to specify a local neighborhood. The quantile
kernel will be applied to each pixel in r. Dimensions must be non-zero
and odd.
q
A quantile. This value is required to be in the inclusive interval from 0 to 100.
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
quantile of the neighborhood identified by W. Only non-missing or neighbors
with non-zero weights are used in the calculation. Quantile calculation uses
the inverse empirical CDF transform, equivalent to stats::quantile type=1.
Value
An in memory raster image of local quantiles.
Examples
r <- raster::raster( matrix(rnorm(36),6,6))
W <- matrix(1,3,3)
medianR <- rasterLocalQuantiles(r,W)
Local sums for an in memory raster image.
Description
rasterLocalSums finds the local sum within the weighted neighborhood of W.
Usage
rasterLocalSums(r, W)
Arguments
r
An in memory raster image.
W
A matrix of weights. The sums will be applied at each centroid. Dimensions must be non-zero and odd. Only non-missing neighbors are used in the sum.
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 sum of
all pixels within the neighborhood weighted by W. Only non-missing
or neighbors with non-zero weights are used in the calculation.
Value
An in memory raster image of local sums.
Examples
r <- raster::raster( matrix(rnorm(36),6,6))
W <- matrix(1,3,3)
sumR <- rasterLocalSums(r,W)