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 1, Automating QGIS,
How to do it...
We'll start with a DEM and compute its slope. Then, we'll load a road vector layer and break it into interval lengths of 500 meters. Next, we'll load the layer and style it using green, yellow, and red values for each segment to show the range of steepness....