# Calculating slope over distance from raster

I am sitting with an elevation raster, trying to produce a calculation for slope angle. I have a cell size of 2,-2 and I am trying to figure out how to calculate cell value difference between adjacent cells. Or is there another way to visualize the slopiest slopes in my raster? I am currently using QGIS and SAGA.

I know this is not addressing your query directly, i.e., I can't give you info on calculating slope yourself. But you can calculate slope using a built in tool, well, a plugin.

If you want to calculate it yourself then let me know and we can find out how to do raster calculations manually. Here's how to calculate it: http://en.wikipedia.org/wiki/Geographic_information_system#Slope_and_aspect

You can do the slope calculation on your own using GRASS plugin from QuantumGIS or you can use a predefined function that compute slope available also in GRASS or SAGA plugin.

For your own calculation you must run raster calculator which is a GRASS function. To use GRASS within QGIS you must have installed one of the latest version of QGIS, for example 1.7.4. If you do right click on the top of QGIS window you can choose to reveal GRASS toolbox. Then you will see the GRASS toolbox, where you must create or open a MAPSET. The you can Open GRASS tools and use r.mapcalc to run this (called 2FD algorithm):

``````atan(sqrt(((raster@PERMANENT[0,-1]-raster@PERMANENT[0,1])/(2*resolution))^2+((raster@PERMANENT[-1,0]-raster@PERMANENT[1,0])/(2*resolution))^2))
``````

where

• raster is the name of your raster
• resolution is the cell size
• [0,-1] points to the northern pixel from central pixel
• [0, 1] points to the southern pixel from central pixel

For calculations already implemented you will find in GRASS tools the r.slope.aspect.slope function.