raster.gaussian.smooth: Gaussian smoothing of raster

View source: R/raster.gaussian.smooth.R

raster.gaussian.smoothR Documentation

Gaussian smoothing of raster

Description

Applies a Gaussian smoothing kernel to smooth raster.

Usage

raster.gaussian.smooth(
  x,
  s = 2,
  n = 5,
  scale = FALSE,
  type = c("mean", "median", "sd", "convolution"),
  ...
)

Arguments

x

A terra SpatRaster raster object

s

Standard deviation (sigma) of kernel (default is 2)

n

Size of the focal matrix, single value (default is 5 for 5x5 window)

scale

(FALSE/TRUE) Scale sigma to the resolution of the raster

type

The statistic to use in the smoothing operator; "mean", "median", "sd", "convolution"

...

Additional arguments passed to terra::focal

Details

This applies a Gaussian Kernel smoother. The convolution option performs a Gaussian decomposition whereas the other options use the kernel as weights for the given statistic.

Value

A terra SpatRaster class object of the local distributional moment

Author(s)

Jeffrey S. Evans <jeffrey_evans@tnc.org>

Examples

library(terra)
elev <- rast(system.file("extdata/elev.tif", package="spatialEco"))

# Calculate Gaussian smoothing with sigma = 2 and 7x7 window
g1 <- raster.gaussian.smooth(elev, s=2, n=7)
    plot(c(elev,g1))


spatialEco documentation built on Nov. 18, 2023, 1:13 a.m.