My last bit of the puzzle is to create the flow direction raster. How do I reclassify in order to get the stream direction using r.mapcalc?
Hi Shane,
You are welcome. What you need to do are 2 steps: 1) vector to raster conversion with direction to be used for raster values:
v.to.rast input=streams output=streams_direction use=dir
The v.to.rast manual says: “line direction in degrees CCW from east” [1]. However, the r.stream.distance manual specifies the drainage direction to be: “…zero and negative values are valid direction data only if they vary from -8 to 8 (CCW from East in steps of 45 degrees). Flow direction map shall be of integer type (CELL).” So you need to reclassify.
[1] https://grass.osgeo.org/grass74/manuals/v.to.rast.html
[2] https://grass.osgeo.org/grass74/manuals/addons/r.stream.distance.html
The reclassification with r.mapcalc would be something like the following, but I didn’t really check and it may be wrong. Alternative would be to use r.recode.
r.mapcalc “streams_direction_8 = int((streams_direction + 45) / 45)”
So please double check the output from the above and compare it with what you get from r.watershed.
For completeness, here is what I wrote before:
“”"
Yes, just convert your streams to raster (presence-absence) and a raster for flow direction as I mentioned here:
https://lists.osgeo.org/pipermail/grass-user/2018-September/079135.html
Since you already have the streams and you want to use them, you need to convert them to raster and then also get stream direction for r.stream.distance by reclassifying, e.g. with r.mapcalc, output from something like this:
v.to.rast in=streams output=streams_dir use=dir
which you can see in context here (different hydrology tool):
http://ncsu-geoforall-lab.github.io/geospatial-modeling-course/grass/simwe.html
“”"
···
Image attached shows rivers (black line) and floodplain of where it thinks there are rivers and in some cases where there may not be rivers.