There are several ways to calculate slope in qgis using a DEM layer, but how does it actually work? My results show pixels with a slope of 40°+, this seems like a lot (in my DEM, one pixel is 25*25 m). Does it mean that the average slope of the pixel is for example 30° and in reality it could be that the pixel is actually quite flat, but there's a small part of it with really steep slope?

  • Have you looked at the source code to see how it is done?
    – Ian Turton
    Commented May 1, 2021 at 18:01

1 Answer 1


A pixel represents a point. It has no length or width. Slope comes from the relationship between the height of the point and that of neighbouring points, and the distance between them. It is the inverse tangent of the quotient of the difference in height and difference in lateral position

slope = arctan(dy/dx)

In practice, it can be an average or other statistical aggregate of the slope between the point under consideration and several of its neighbours. If you look at the Wikipedia description of image gradient, you can see the mathematics typically involved.

Further, rather than looking at immediately adjacent pixels only, the span of the gradient calculation can be larger. which will generally give a smoother result.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.