In QGIS, I have a Digital Terrain Model. Using Slope (Menu Raster > Analysis > Slope..., in fact using GDAL Slope algorithm), I get an output raster, either in percents or degrees, the same principle as described here for ArcGIS. So far, so clear.
The question I have is (I guess) not so software specific, but more a general, conceptual question: how is the slope of a cell calculated, based on a raster DEM?
I can't make any sense of the values of my slope raster. I tried to manually calculate the slope value and I'm not sure how it is calculated: I suppose that eight neighboring cells are used for calculation. So the slope is calculated separately for each of these 8 neighbours? And then some kind of mean value is calculated?
Based on the data I got, I was not able to come even close to the slope raster's values by calculating this value manually. See screenshot for example data with a point grid, labeled with the elevation and slope values (0.5*0.5 m, corresponding to resolution and CRS of elevation and slope rasters). So how can you calcaluate the slope of 41.1% the cell indicated in yellow from the 8 neighbours (point 2)? Horizontal distance is 0.5, slope is in percent:
- Elevation current cell: 504.58
- Elevation 8 neighbours, red values (clockwise, from upper left): 504.75, 504.64, 504.51, 504.35, 504.15, 504.33, 504.3, 504.56
- Slope current cell, yellow value: 41.1
Based on the graphic linked by @FelixIP (see below), I manually calculated the angles (slope) of each cell with this forumula (pseudocode):
degrees (arctan ((elevation(a)-elevation(e))/distance)) = slope-angle, where distance is 0.5 for cells b,f,h, and d (straight line from centroid to centroid) and 0.707=
sqrt(0.5^2+0.5^2) for a,c,i,g (diagonal distance from centroid to centroid).
The resulting angles in degree looks like. So the question, more specifically, is: how do these values relate to the slope in degrees calculated for cell e as 41.1 degrees? None of these values seems to be close to the result:
Manually calculated slope angle from each cell to cell
a 13.51828463 b 6.842773413 c -5.653572474 f -24.70243023 i -31.30427926 h -26.56505118 g -21.60256512 d -2.290610043