1

r.drain was obviously originally intended to be used for drainage catchment, which is a problem when trying to find a least-cost walking path, as r.drain is happy to send you walking down a riverbed.

I've thought of blocking areas with either "nodata" or 9999 value cells, but i'm not really sure how exactly to do this. Is there an easy way?

  • 1
    Have you tried r.cost – Micha Dec 6 '18 at 9:00
  • Yep, my workflow is to use r.walk (or r.cost, the output is similar for building a cost map) and then running r.drain on the resulting cost map to give me actual vector lines showing a path. Unfortunately, r.walk and r.cost both have no way to tell whether a particular area of the terrain is "walkable" or not, so they treat a steep-sided gully or riverbed as if it were easily walkable. Thank you for the suggestion, though. If you have any more i'd be happy to hear them! – BogBody Dec 6 '18 at 16:08
  • 1
    r.walk has the option for a friction map. You could create a raster with very high values for all riverbeds as the firction map, then r.walk would avoid paths that go into the riverbeds. – Micha Dec 7 '18 at 11:02
  • Do you have any suggestions for how to create that initial raster map with high values for all the riverbeds, though? I mean, do I need to load this into photoshop and change the gradient manually? Is there a more elegant way to do this within QGIS? – BogBody Dec 7 '18 at 17:00
1

I gather from your post that you have an elevation map? You could run r.stream.extract to get a raster map of streams. The module sets a random value to each stream section, so you would want to reclassify the stream map to give some high value to the streams, (with NULL everywhere else). i.e. (if your elevation map is called 'elev', and your cost map is 'cost')

r.stream.extract elevation=elev stream_rast=streams
r.mapcalc "stream_friction = if( stream_rast >=1, 1000, null() )"
r.walk elevation=elev friction=stream_friction output=path start_coord=<x start>,<y start> stop_coord=<x stop>,<y stop>

If you want to get more detail, you could run r.watershed to produce a flow accumulation map. This map contains how many cells are "upstream" at all locations. So larger streams have higher accumulation values, and small tributaries have small accumulation values. Using this as a start for your friction map would allow your path to cross small creeks, but be blocked by larger rivers...

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.