Concepts
Least-cost path & global optimality
Why the route is the globally optimal corridor, not a greedy guess.
Given the cost surface, the optimal route is the path that minimises the accumulated cell cost from origin to destination:
CO2GIS computes this with a chain of GRASS GIS algorithms, run through QGIS Processing.
The GRASS chain
| Step | Algorithm | What it does |
|---|---|---|
| 1 | r.cost | Propagates the accumulated minimum cost from the origin across the whole cost surface (a raster Dijkstra). Also emits a movement-direction surface. Diagonal moves are allowed for better geometric fidelity. |
| 2 | r.drain | Back-traces from the destination, following the descending gradient of the accumulated-cost surface back to the origin → a path raster. |
| 3 | r.thin | Reduces the path to unit width, so it has clean line topology. |
| 4 | r.to.vect | Converts the thinned path raster into a line vector for display and for CAPEX. |
Why it’s globally optimal
r.cost computes the true accumulated-cost value for every cell, considering all ways of reaching it — not just local neighbours. Because the full surface is solved first, r.drain recovers the globally optimal corridor, not a greedy local path that can get trapped by nearby cheap cells.
The route minimises cost, not distance. It will happily take a longer geometric path if that avoids expensive terrain — which is exactly the point.
Next: see how the route is priced in The COMET cost model (the “same factors, twice” idea) and the per-tab LCP and Price Estimation pages.