7

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.

1

3 Answers 3

16

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

1
  • First i struggeld with the v.drape tool. The tool did run but i wouldn't generate any outcome. I realized only then that the file path contained a 'ü' letter and thats why it didn't work. Thanks for your help everybody. Mar 5, 2018 at 10:31
13

This is a modification of Kazuhito's answer using native QGIS algorithms using QGIS 3.12.
In the QGIS Processing Toolbox, there are the tools Split lines by maximum length and Drape (set Z value from raster).

Before starting;

0.) make sure your DEM and road data are projected onto the same CRS.(This is no longer strictly necessary in QGIS 3.x using native algorithms but helpful to reduce unexpected issues. More importantly check that your elevation values and CRS Horizontal distance values are in the same units in both of your layers.)

Then, following your summary workflow:

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

Split lines by maximum length will give you a new layer Split.

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

Drape (set Z value from raster) will give you a new 3D vector layer Updated.

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

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

A breakdown of the formula:

abs = Absolute value to get rid of the negative numbers

z(start_point($geometry) = The elevation of the first vertex in your line

z(end_point($geometry) = The elevation of the last vertex in your line

$length = The length of your line

*100 = Makes it a percent

6

There is a new QGIS plugin called Road Slope Calculator that seems to do this. Quoting its project description:

This algorithm is used to calculate the longitudinal slope of forest paths and roads, based on a 2D line vector layer and a DEM (Digital Elevation Model)...

Your Answer

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

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