Is there a possibility in QGIS 2.14.1 Essen, when you select a contour line and give a fixed length of line, this line connects automatically to the next contour lines?

I have two other questions on this subject but I do not have an adequate response:

This is very important for the design of forest roads, to select an optimum zero line, depending on the longitudinal inclination of the forest road. (1-12%).

enter image description here

  • There is no standard function to do this of which I am aware. But it is fairly simple to calculate if you know python or similar? Just iterate along the vertices of the lower contour and calculate the distance to the relevant point on the upper contour until the the desired length is reached.
    – AnserGIS
    May 23 '16 at 12:20
  • There is no vertices, only contours. In fact, I need a dialog box, when I enter, for example, 10% of longitudinal slope, automatically connects the next contour lines with line between, and next, next.... This example better show a problem: gis.stackexchange.com/questions/131702/…. I am begginer in Python.
    – nagib
    May 23 '16 at 12:39
  • 3
    All lines have vertices. You can see how to iterate through them here gis.stackexchange.com/questions/187162/…
    – AnserGIS
    May 23 '16 at 13:05
  • Thanks, but I think this is too hard for me.
    – nagib
    May 23 '16 at 15:49
  • @AnserGIS your suggestion work for straight contours. In real world it is rather complex task and don't forget there are 2 possible solutions I.e. heading 'left' and 'right'
    – FelixIP
    May 24 '16 at 19:03

This may be possible in a manual sort of way using the 'Advanced Digitizing Tools' enter image description here

Using this tool you can specify a distance. Then you just need to set up your snapping options to snap on intersection with your contour layer. As you can see in the image below a dark blue circumference guide helps you visualize the extent of your reach.

enter image description here

  • I think this is a good solution. If scripted, what would happen when there is no contour within the specific distance? Or if there are two contours. May 25 '16 at 12:01
  • Thanks Knightshound, this is very useful. Thank you all for your help. In the future should do something like this: youtube.com/watch?v=OblXzu2Dhb8
    – nagib
    May 25 '16 at 16:45

If I understand your question, you want to design a road thru a sloped terrain, with start and end points. And you need to keep the slope of the road at minimum. If this is the case, then working with contour lines just complicates the process. There are "least cost path" tools available that work on raster layers. So you should revert your contour lines back to an elevation raster (from the grey scale pixels above, it looks like you already have an elevation raster) then, using i.e. GRASS GIS modules r.cost and r.drain you can create your minimum slope road like so:

# First create an elevation raster, if you don't have it
v.to.rast <your_contour_lines> output=contour_rast
r.surf.contour contour_rast output=elev
# Use the elevation to create a cost surface, then find least cost path
r.cost elev output=elev_cost start_coord=<your_start_x,your_start_y> stop_coord=<your_stop_x,your_stop_y> outdir=dir
r.drain -d elev_cost direction=dir output=road
# Convert raster output to line vector
r.thin road output=road_thin
r.to.vect road_thin type=line output=roads  
  • Is it correct to use the elevation layer with the drain tool, as the output would be the lowest elevation value across the path. This would essentially OK any sharp changes in elevation. If the drain tool was used on Least Cost of Slope layer, then the drain tool would find a path of least change of slope angle, effectively finding the smoothest path. Now this is where I could be completely wrong, but would it be better to use the raster calculator and multiply the cost of elevation with the cost of slope, effectively giving the smoothest route of least elevation change? May 25 '16 at 15:37
  • Not sure I understand what you are asking, but the r.cost module creates a surface of "cost" moving from one pixel to the next, i.e. change in elev. pixel by pixel, from the start point to the end. Then r.drain works out the path by finding the chain of pixels of minimum change in elevation. AFAIK, there's no need for any additional calculations
    – Micha
    May 26 '16 at 7:55
  • It's probably me, but the "r.cost" manual describes the DEM as a cost surface. "r.cost" finds cumulative cost across the DEM. This means "r.cost" maintains lowest elevations as cheapest. Imagine a horse-shoe hill that softly rises from tips to middle where there's a cliff down to a valley in the centre. As "r.drain" is regressive the path will drop down the cliff to follow the valley. Using slope would Identify the cliff as a high degree of change, & a higher cost, & "r.drain" would then have to follow the smoother descent of the horse shoe sides because of the reduced change in slope angle. May 26 '16 at 9:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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