rasterLocalSums: Local sums for an in memory raster image.

Description Usage Arguments Details Value Examples

View source: R/rasterLocalSums.R

Description

rasterLocalSums finds the local sum within the weighted neighborhood of W.

Usage

1

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

1
2
3
r <- raster::raster( matrix(rnorm(36),6,6)) 
W <- matrix(1,3,3)
sumR <- rasterLocalSums(r,W)

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