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...
r.cost
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, thenr.walk
would avoid paths that go into the riverbeds.