Computing road slope using elevation data

A common geospatial workflow is to assign raster values to a coincident vector layer so that you can style or perform further analysis on the vector layer. This recipe will use this concept to illustrate the steepness of a road using color by mapping values to the road vector from a slope raster.

Getting ready

You will need to download a zipped directory from https://github.com/GeospatialPython/Learn/raw/master/road.zip and place the directory, named road, in your qgis_data directory.

You must also have a verison of QGIS which includes GRASS and SAGA. For more information, see the Installing QGIS for development recipe from Chapter 1Automating QGIS,

How to do it...

We'll start with a DEM and compute its slope. ...

Get QGIS Python Programming Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.