I have contour information in the form of line features (see picture below) and I want to do a slope analysis in QGIS. Is it possible?

enter image description here

  • What exactly are you looking for when you say slope analysis? May 23, 2016 at 7:36
  • Such an analysis requires a raster layer... I can't see even one layer in the TOC on the image attached in your question.
    – wiltomap
    May 23, 2016 at 8:06

2 Answers 2


Slope analysis is performed on a DEM (raster layer with elevation values). This is one way to do it. If your contours have an elevation value, you can use the interpolation option (raster/interpolation) to produce a DEM. For instance, here are my contours as a shapefile

enter image description here

The attribute table do have a value for altitudes in the "elevacion" field.

enter image description here

Now you can use the interpolation plugin (raster interpolation) to produce a DEM:

enter image description here

Notice that I declare "elevacion" as my interpolation field, set the proper cell size for x and y. Also, bear in mind that the resulting raster will be in asc format. This is the resulting DEM.

enter image description here

Now you can use the DEM (terrain models) module to perform the slope analysis (Raster/analysis/DEM-terrain models). This is the dialog box:

enter image description here

You have to set input DEM, the output file and set the mode to slope. You can chose to get the slope either in degrees or as percent.

Bear in mind that the option "scale (ratio of vertical units to horizontal units)" is very important. When a DEM is in a lat lon CRS such as 4326 you can set this option to 111120 if vertical units are in meters or 370400 if they are in feet. You can set this parameter to 1 only when the measuring units of the CRS and the elevation measuring units are the same.

This is the slope map produced:

enter image description here

  • I noticed that in recent versions of Qgis (2.14.8 and 2.18) the interpolation attribute must be a real number (one that allows to have decimals) not an integer one. So if you want to use it you can use the field calculator to convert your ineteger you can multiply times 1 your altitude value and store the result in a "decimal (real)" field. Nov 7, 2016 at 17:24

In QGIS in order to do slope analysis, you need to convert the contour lines first into a raster DEM, then you can use Raster -> Terrain Analysis -> Slope. However, there is no direct tool that can help you to convert the contour line to DEM. The closest possible tool to do that is to use r.surf.contour located under Processing Toolbox -> Grass -> Raster -> r.surf.contour. But even using r.surf.contour is a little bit tedious and requires some processing because it requires that your contour line should be converted first into raster. the tool cannot accept vector line as input, it requires raster file as input, which means you need to rasterize your contour line first. You can convert vector to raster using Processing Toolbox -> GDAL Conversion -> Rasterize (Vector to Raster)

If you have access to ArcGIS with "Spatial Analyst Extension", there is a tool called Topo to Raster . This tool has the correct algorithm to produce directly a correct DEM from vector contour line. If you do not have access to ArcGIS with "Spatial Analyst Extension". Then you need to try r.surf.contour in QGIS, which is the only option that you have.

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