[GIS] Calculate slope of line segments with QGIS

lineqgisslope

I want to calculate the slope of a forest road in mountainous areas.
No problem with ArcGIS following the instructions of the following post:

(see comment of user 'FelixIP')
How do I find the slope of road segments with point elevation data of the same linear path

Summary:
1.) split line (forest road) into equal lengths segments
2.) convert segments to 3D shapes (Interpolate shape tool)
3.) calculate slope of each segment with the field calculator ->

  abs( !Shape!.lastPoint.Z- !Shape!.firstPoint.Z)/ !Shape!.length*100

The output are slope values for every line segment of that polyline. In the attribute table, every segment has its individual slope value now.

This works with ArcGIS. Now I would like to do the same with QGIS.
I tried to use the point sampling tool, tried to rasterize the polyline, tried 'QChainage', the Topology checker and the pProf plugin but it didn't bring the expected results.

Best Answer

In the QGIS Processing Toolbox, there are GRASS tools v.split.length and v.drape (using QGIS 2.18.16).

Before starting;

0.) make sure your DEM and road data are projected onto the same CRS.

Then, following your summary workflow:

1.) split line (forest road) into equal lengths segments

v.split.length will give you a new layer Split by length by default.

2.) convert segments to 3D shapes (Interpolate shape tool)

v.drape will give you a new 3D vector layer.

3.) calculate slope of each segment with the field calculator

abs(z(start_point($geometry)) - z(end_point($geometry)))/$length*100