[GIS] Using DTM slope map to find shortest route between two locations using QGIS

demqgisshortest path

I've got two locations, A and B, and a DTM covering the region between A and B. Say I want to drive from A to B. I want the shortest route possible, but avoiding regions with slopes higher than, let's say 30 degrees.

Can QGIS calculate such a path?

If needed I can also script using python.

Best Answer

There's a python example in the GDAL/OGR Raster Cookbook (look for 'Least Cost Path analysis'). You'll need to install scikit-image for that.

If using QGIS:-

  • To get your cost raster, generate a slope raster in the usual way
  • then use Raster Calculator to set any slope pixel above a threshold to a really high value like 9999
  • to find your coordinates for the script, use the Coordinate Capture plugin

That will find the route with the least overall slope between A and B. The output is a binary raster.

It won't necessarily be the shortest path distance-wise, but it would represent the easiest route between A and B (for example, for hillwalkers or cyclists)

Related Question