slopeAspect
terrain(x, filename='', opt='', unit='radians', neighbors=8, ...)
neighbors=4
, slope and aspect are computed according to Fleming and Hoffer (1979) and Ritter (1987). When neigbors=8
, slope and aspect are computed according to Horn (1981). The Horn algorithm may be best for rough surfaces, and the Fleming and Hoffer algorithm may be better for smoother surfaces (Jones, 1997; Burrough and McDonnell, 1998).
If slope = 0, aspect is set to 0.5*pi radians (or 90 degrees if unit='degrees'). When computing slope or aspect, the CRS (projection
) of the RasterLayer x
must be known (may not be NA
), to be able to safely differentiate between planar and latitude/longitude data.
The terrain indices are according to Wilson et al. (2007), as in focal
function:
f <- matrix(1, nrow=3, ncol=3)
TRI <- focal(x, w=f, fun=function(x, ...) sum(abs(x[-5]-x[5]))/8 )
TPI <- focal(x, w=f, fun=function(x, ...) x[5] - mean(x[-5]))
rough <- focal(x, w=f, fun=function(x, ...) max(x) - min(x))
hillShade
elevation <- getData('alt', country='CHE')
x <- terrain(elevation, opt=c('slope', 'aspect'), unit='degrees')
plot(x)
Run the code above in your browser using DataLab