Learn R Programming

SurfRough (version 0.0.1.2)

stdST: stdST: standard deviation in a moving window

Description

A function to compute standard deviation in a moving window. By default it uses the implemented rcpp version that is many times faster that using focal with var() base R function. It provides the same result as ArcGis Pro. It is intended for computing roughness indices expressed as dispersion of local surface parameters (e.g., slope, profile curvature, residual surface, etc.). Whenever there is a NA in the kernel the result is NA. R base var() function uses n-1 at the denominator, here we use n.

Usage

stdST(x, w = 5, ...)

Value

the STD of the selected property in the search window (same units of the input)

Arguments

x

A DEM/image as a SpatRaster

w

Search window (e.g., kernelCircular(3)), default 5x5 window

...

for further use

References

Trevisani, S., Guth, P.L., 2025. Surface Roughness in Geomorphometry: From Basic Metrics Toward a Coherent Framework. Remote Sensing 17, tools:::Rd_expr_doi("doi:10.3390/rs17233864").

Examples

Run this code
library(terra)
dem= rast(paste(system.file("extdata", package = "SurfRough"), "/trento1.tif",sep=""))
# std of slope in degrees
slope=terrain(dem, v="slope")
w=KernelCircular(3)
w
stdSlope=stdST(slope,w=w)
plot(stdSlope)

Run the code above in your browser using DataLab