Slope and aspect calculations were adapted from functions in package 'SDMTools', which used the approach described in Burrough & McDonell (1998).
The rate of change (delta) of the surface in the horizontal (dz/dx)
and vertical (dz/dy)
directions from the center cell determines the slope and aspect. The values of the center cell and its eight neighbors determine the horizontal and vertical deltas. The neighbors are identified as letters from 'a' to 'i', with 'e' representing the cell for which the aspect is being calculated. The rate of change in the x direction for cell 'e' is calculated with the algorithm:
[dz/dx] = ((c + 2f + i) - (a + 2d + g) / (8 * x_cell_size)
The rate of change in the y direction for cell 'e' is calculated with the following algorithm:
[dz/dy] = ((g + 2h + i) - (a + 2b + c)) / (8 * y_cell_size)
The algorithm calculates slope as: rise_run = sqrt ( [dz/dx]2 + [dz/dy]2 ])
.
From this value , one can calculate the slope in degrees or radians as:
slope_degrees = ATAN (rise_run) * 57.29578
slope_radians = ATAN (rise_run)
Taking the rate of change in both the x and y direction for cell 'e', aspect is calculated using:
aspect = 57.29578 * atan2 ([dz/dy], -[dz/dx])
The aspect value is then converted to compass direction values (0-360 degrees).