Title: | Kernel Based Estimates on in-Memory Raster Images |
---|---|
Description: | Performs kernel based estimates on in-memory raster images from the raster package. These kernel estimates include local means variances, modes, and quantiles. All results are in the form of raster images, preserving original resolution and projection attributes. |
Authors: | Jonathan Lisic [aut, cre] |
Maintainer: | Jonathan Lisic <[email protected]> |
License: | MIT + file LICENSE |
Version: | 1.0.2 |
Built: | 2024-11-08 06:23:09 UTC |
Source: | CRAN |
rasterLocalCategoricalModes
finds the most popular category within the
weighted neighborhood of W
.
rasterLocalCategoricalModes(r, W)
rasterLocalCategoricalModes(r, W)
r |
An in memory raster image. Pixels should be whole numbers or |
W |
A matrix of weights. The modal kernel will be applied to each
pixel in |
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.
An in memory raster image by most popular categories.
r <- raster::raster( matrix(runif(81),9,9)) W <- matrix(1,3,3) modeR <- rasterLocalCategoricalModes(r,W)
r <- raster::raster( matrix(runif(81),9,9)) W <- matrix(1,3,3) modeR <- rasterLocalCategoricalModes(r,W)
rasterLocalMoments
finds the local moments within the weighted neighborhood
of W.
rasterLocalMoments(r, WMu, WVar = WMu, moments = 2)
rasterLocalMoments(r, WMu, WVar = WMu, moments = 2)
r |
An in memory raster image. |
WMu |
A matrix of weights. The mean kernel will be applied to each
pixel in |
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. |
A list of in memory raster images, one list element for each moment.
r <- raster::raster( matrix(rnorm(36),6,6)) W <- matrix(1,3,3) rLocalMoments <- rasterLocalMoments(r,W)
r <- raster::raster( matrix(rnorm(36),6,6)) W <- matrix(1,3,3) rLocalMoments <- rasterLocalMoments(r,W)
rasterLocalQuantiles
finds the quantile within the positive valued neighborhood
of W
.
rasterLocalQuantiles(r, W, q = 50)
rasterLocalQuantiles(r, W, q = 50)
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 |
q |
A quantile. This value is required to be in the inclusive interval from 0 to 100. |
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.
An in memory raster image of local quantiles.
r <- raster::raster( matrix(rnorm(36),6,6)) W <- matrix(1,3,3) medianR <- rasterLocalQuantiles(r,W)
r <- raster::raster( matrix(rnorm(36),6,6)) W <- matrix(1,3,3) medianR <- rasterLocalQuantiles(r,W)
rasterLocalSums
finds the local sum within the weighted neighborhood of W.
rasterLocalSums(r, W)
rasterLocalSums(r, W)
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. |
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.
An in memory raster image of local sums.
r <- raster::raster( matrix(rnorm(36),6,6)) W <- matrix(1,3,3) sumR <- rasterLocalSums(r,W)
r <- raster::raster( matrix(rnorm(36),6,6)) W <- matrix(1,3,3) sumR <- rasterLocalSums(r,W)