I have previously asked for help regarding this issue Finding least cost path in QGIS?, but obviously people do not know exactly the problem related to road design I used the least cost path, this time in ArcGIS, and got the result as shown below. Other lines are automatically generated with the module least cost path, where the cost raster use slope raster.You can see that the obtained trajectory can not possibly be as roads.

enter image description here

Red lines represent the paths that I hand-drew under rule: In my case a roads may not have longitudinal slope greater than 10%, can be between 1-10%.

What is the longitudinal slope of the terrain?

If the height difference between two contour lines 10m, longitudinal gradient of 10% is the line that connects the two contour lines at 100m, for 8% distance is 125m ... the formula looks like this: K = E / L-slope

K- step
e - equidistance
L - longitudinal slope of road

enter image description here

Is it possible to use longitudinal slope as raster cost for road design?

If we solve this, we finally resolve the issue of the optimal network paths.


1 Answer 1


Connecting 2 points on contours by straight line is not going to work, as seen on your second picture line crosses same contour twice. I also very much doubt that any out of the box tools can help you. You'll need to invest heavily in scripting.

Funny enough people in the past were able to solve this task by tracing footsteps of heavily loaded donkey. Smart and laizy (or other way around) animal is able to pick the most efficient = same gradient = path on it's way home. This is why I called relevant tool DonkeyTheDesigner. I applied it on subset of your contours and after 3 iterations found that 1:33 gradient is the best option to go between 2 points shown: enter image description here

I am not willing to share the code for free but general workflow is as follows:

  • define the direction of route by flipping when necessary contours of interest towards higher point. Without this there are infinite number of solutions to reach upper contour from lower, e.g. zig-zag
  • Connect vertices of contours using triangulation. Remove horizontal connections and flip ones that head downhill.
  • Assume linear change of elevation between contours along connections
  • Take the start point of connection nearest to source point and find point on next connection towards destination with matching grade.
  • Continue untill number of next connections equal zero.

Picture below explains algorithm and also shows line manually drawn by you, - RULE:

enter image description here

Yes, my donkey is climbing ...


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.