spatialEco (version 2.0-2)

spherical.sd: Spherical Variance or Standard Deviation of Surface

Description

Derives the spherical standard deviation of a raster surface

Usage

spherical.sd(r, d, variance = FALSE, ...)

Value

A terra SpatRaster class object of the spherical standard deviation

Arguments

r

A terra SpatRaster class object

d

Size of focal window or a matrix to use in focal function

variance

(FALSE|TRUE) Output spherical variance rather than standard deviation

...

Additional arguments passed to terra:app (can write raster to disk here)

Author

Jeffrey S. Evans <jeffrey_evans<at>tnc.org>

Details

Surface variability using spherical variance/standard deviation. The variation can be assessed using the spherical standard deviation of the normal direction within a local neighborhood. This is found by expressing the normal directions on the surfaces cells in terms of their displacements in a Cartesian (x,y,z) coordinate system. Averaging the x-coordinates, y-coordinates, and z-coordinates separately gives a vector (xb, yb, zb) pointing in the direction of the average normal. This vector will be shorter when there is more variation of the normals and it will be longest--equal to unity--when there is no variation. Its squared length is (by the Pythagorean theorem) given by: R^2 = xb^2 + yb^2 + zb^2 where; x = cos(aspect) * sin(slope) and xb = nXn focal mean of x y = sin(aspect) * sin(slope) and yb = nXn focal mean of y z = cos(slope) and zb = nXn focal mean of z

The slope and aspect values are expected to be in radians. The value of (1 - R^2), which will lie between 0 and 1, is the spherical variance. and it's square root can be considered the spherical standard deviation.

See Also

app for details on ... arguments

Examples

Run this code
# \donttest{
 library(terra)
 elev <- rast(system.file("extdata/elev.tif", package="spatialEco"))
 
 ssd <- spherical.sd(elev, d=5)
 
 slope <- terrain(elev, v='slope')
 aspect <- terrain(elev, v='aspect')
 hill <- shade(slope, aspect, 40, 270)
 plot(hill, col=grey(0:100/100), legend=FALSE, 
      main='terrain spherical standard deviation')
   plot(ssd, col=rainbow(25, alpha=0.35), add=TRUE)
# }
 

Run the code above in your browser using DataLab