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 1Automating 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 ...

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.