With -n flag, the module will count the number of upstream cells plus one and convert it to the negative if any upstream cells are likely to receive flow from outside the computational region (flow direction edges). Negative values identify cells with likely underestimates because not all upstream cells were accounted for. Since raster map weight may contain negative flow weights, -n flag is not compatible with weight option. Running the module twice with and without -n flag and weight option may be useful in this specific case.
The module recognizes two different formats of the flow direction map:
Direction encoding for neighbors of x 135 90 45 3 2 1 180 x 360 4 x 8 225 270 315 5 6 7 degrees 45 degrees CCW from East CCW from East (r.watershed drainage)
Since the module does not use elevation data (i.e., slope), flow accumulation is calculated by single flow direction (SFD) routing and may not be comparable to the result from multiple flow direction (MFD) routing.
With -c flag, stream lines are delineated across confluences and may overlap with other stream lines that share the same downstream outlet.
Calculate flow accumulation using r.watershed and r.accumulate:
# set computational region g.region raster=elevation -p # calculate positive flow accumulation and drainage directions using r.watershed # for comparison, use -s (SFD) r.watershed elevation=elevation accumulation=flow_accum drainage=drain_directions -s -a # calculate flow accumulation using r.accumulate r.accumulate direction=drain_directions accumulation=flow_accum_new # copy color table r.colors map=flow_accum_new raster=flow_accum # check difference betwen flow_accum and flow_accum_new r.mapcalc expression="accum_diff=if(flow_accum-flow_accum_new, flow_accum-flow_accum_new, null())"
For some reaon, there are slight differences between the two output maps.
The yellow and purple cells show the difference raster map (accum_diff). The red arrows and numbers represent drainage directions (drain_directions) and flow accumulation (flow_accum from r.watershed), respectively. Note that some cells close to headwater cells are assigned 1 even if they are located downstream of other cells.
For comparison, these numbers show the new flow accumulatoin (flow_accum_new from r.accumulate). The same cells are properly accumulated from the headwater cells.
Calculate flow accumulation and delineate stream networks at once:
# set computational region g.region raster=elevation -p # calculate positive flow accumulation and drainage directions using r.watershed # for comparison, use -s (SFD) r.watershed elevation=elevation accumulation=flow_accum drainage=drain_directions -s -a # use r.accumulate to create flow_accum_new and streams_new at once r.accumulate direction=drain_directions accumulation=flow_accum_new threshold=50000 stream=streams_new # or delineate stream networks only without creating an accumulation map r.accumulate direction=drain_directions threshold=50000 stream=streams_new_only # use r.stream.extract, elevation, and flow_accum_new to delineate stream networks r.stream.extract elevation=elevation accumulation=flow_accum threshold=50000 stream_vector=streams_extract direction=drain_directions_extract
In this example, r.accumulate and r.stream.extract produced slightly different stream networks where the flow turns 90 degrees or there are multiple downstream cells with the same elevation. The following figure shows an example where the streams (red from r.stream.extract) and streams_new (blue from r.accumulate) vector maps present different stream paths. The numbers show cell elevations (elevation map), and the yellow (drain_directions map) and green (drain_directions_2 map) arrows represent flow directions generated by r.watershed with -s flag and r.stream.extract, respectively. Note that the two flow direction maps are different.
Create the longest flow path for one outlet:
# set computational region g.region raster=elevation -p # calculate drainage directions using r.watershed r.watershed elevation=elevation drainage=drain_directions -s -a # delineate watershed r.water.outlet input=drain_directions output=basin coordinates=642455,222614 # calculate longest flow path r.accumulate direction=drain_directions lfp=lfp coordinates=642455,222614
Note that there can be more than one longest flow path when multiple paths have the same flow length. In fact, the above example produces two lines with the same length.
There are different ways to calculate multiple longest flow paths in one run:
# set computational region g.region raster=elevation -p # calculate drainage directions using r.watershed r.watershed elevation=elevation drainage=drain_directions -s -a # calculate longest flow paths at two outlets r.accumulate direction=drain_directions lfp=lfp coordinates=642455,222614,642306,222734 # calculate longest flow paths at two outlets and assign IDs r.accumulate direction=drain_directions lfp=lfp_w_id coordinates=642455,222614,642306,222734 \ id=1,2 id_column=lfp_id # calculate longest flow paths at all points in the outlets map r.accumulate direction=drain_directions lfp=lfp_at_outlets outlet=outlets # calculate longest flow paths at all points in the outlets map and assign IDs using a column in this map r.accumulate direction=drain_directions lfp=lfp_at_outlets_w_id outlet=outlets \ id_column=lfp_id outlet_id_column=outlet_id # calculate longest flow paths at given coordinates and all points in the outlets map and assign IDs r.accumulate direction=drain_directions lfp=lfp_multi_w_id coordinates=642455,222614,642306,222734 outlet=outlets \ id=1,2 id_column=lfp_id outlet_id_column=outlet_id
Calculate the longest flow paths for sub-watersheds:
# set computational region g.region raster=elevation -p # calculate drainage directions using r.watershed r.watershed elevation=elevation drainage=drain_directions -s -a # get nsres eval `r.info -g map=elevation` # delineate streams using a threshold r.accumulate direction=drain_directions threshold=50000 stream=streams # populate stream lengths v.db.addtable map=streams columns="length double" v.to.db map=streams option=length columns=length # create points along the streams starting from downstream v.to.points -r input=streams output=stream_points dmax=$nsres # find outlets (downstream-most less nsres points) cats=`db.select -c sql="select stream_points_2.cat from stream_points_2 \ inner join stream_points_1 on stream_points_1.cat = stream_points_2.lcat \ where length-along > 0.5*$nsres and length-along < 1.5*$nsres"` cats=`echo $cats | tr " " ,` v.extract input=stream_points layer=2 cats=$cats output=stream_outlets # create the longest flow paths for all outlets r.accumulate direction=drain_directions lfp=lfp id_column=id outlet=stream_outlets outlet_layer=2 outlet_id_column=lcat
Last changed: $Date: 2018-06-30 01:12:23 +0200 (Sat, 30 Jun 2018) $
© 2003-2018 GRASS Development Team, GRASS GIS 7.4.2svn Reference Manual