
QGIS Python Programming Cookbook, Second Edition
By :

A hillshade, or shaded relief, is a technique to visualize elevation data in order to make it photorealistic for presentation as a map. This capability is part of GDAL and is available in QGIS in two different ways. It is a tool in the Terrain Analysis menu under the Raster menu, and it is also an algorithm in the Processing Toolbox.
You will need to download a Digital Elevation Model (DEM) from https://github.com/GeospatialPython/Learn/raw/master/dem.zip.
Unzip the file named dem.asc
and place it in your /qgis_data/rasters
directory. A DEM is a 3D representation of a terrain's surface.
In this recipe, we will load the DEM layer and run the Hillshade
processing algorithm against it. To do this, we need to perform the following steps:
Start QGIS.
From the Plugins menu, select Python Console.
Import the processing
module:
import processing
Load and validate the layer:
rasterLyr = QgsRasterLayer("/qgis_data/rasters/dem.asc...