Terrain attributes can be derived by elevation values on a small neighbourhood of each DEM point.
The major attributes can be calculated from the derivatives of the topographic surface. These derivatives measure the rate of change in elevation in relation with the point location.
In literature are available several methods to compute these derivatives.
In this function the following methods have been implemented:
Evans (1980) - In this method a quadratic surface is fitted on a 3x3 elevation window and the derivatives are calculated using all the 9 cells in the windows.
Zevenbergen and Thorne (1987) - Here a more complex Lagrange polynomial is fitted to the topographic surface.
Moore et al. (1993) and Shary (1995), which are similar to the previous two. For more info refer to Florinsky (1998).
This function works with the package raster.
It takes 3 arguments:
data: the raster object
attr: the terrain attribute to be computed. At the moment the choice is between: "slope", "aspect", "plan.curvature" and "prof.curvature".
method: one of the four method implemented: The choice is between: "evans", "zev.tho", "moore" and "shary".
The output is a raster object.
This is the code: