Finding the least cost path
Least cost path (LCP) analysis is the raster equivalent of network analysis, which is used to find the optimal path between two points in a raster. In this recipe, we'll perform LCP analysis on a Digital Elevation Model (DEM).
Getting ready
You need to download the following DEM and extract the ZIP file to your qgis_data/rasters
directory: https://github.com/GeospatialPython/LeaYou 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 will load our DEM and two shapefiles consisting of start and end points. Then, we'll use GRASS through the Processing Toolbox to create a cumulative cost layer that assigns a cost to each cell in a raster based on its elevation, the value of the other cells around it, and its distance to and from the end points.
Then, we'll use a SAGA processing algorithm to find the least cost...