I want to find the cheapest path or the least cost path from one point to another point. The points are part of a vector map and do not lie on a network. All features being part of the map have different costs assigned as costs/meter to cross.

So far my solution is to rasterize all of the features except the points and perform a least cost path analysis with SAGA GIS. To be able to do least cost path analysis, I first generate an accumulated cost surface with r.cost or SAGA GIS accumulated costs. This however, produces a not perfect vector-line, because the line aligns with the edges of the raster cell and therefore uses a not perfect path. In the image below the produced paths are green and the cost surface is more expensive, the darker the red gets.

enter image description here

Can you think of an improvement of my approach or is there a better method to get a path between the points with taking into account the costs?

  • This thread has a quick explanation and link to another article which provides a walkthrough of the same process using r.reclass and r.mapcalculator in GRASS. Maybe this will produce different results? : gis.stackexchange.com/questions/168453/… Apr 18, 2019 at 13:55

1 Answer 1


I would suggest trying two things to get "smoother" cost paths.

  1. First the r.cost module in GRASS allows using "knight's move" (the -k flag) to find the next cell along the path. This using results in more accurate paths.
  2. Also, when you convert the least cost path raster to line vector, in GRASS use the -s flag to smooth the zigzag corners.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.