[GRASSLIST:6523] Re: r.water.outlet

Hamish hamish_nospam at yahoo.com
Mon Apr 18 08:12:28 EDT 2005


> >> I'm having trouble coming up with the drainage direction input for 
> >> r.water.outlet. The documentation indicates that the input should
> >> come from r.watershed but I'm working with large DEMs and
> >> r.watershed is too  slow.

try on a small area and compare outputs.

> >> It seems like I should be able to use flow direction from 
> >> r.fill.dir in AGNPS format but it doesn't work out. r.fill.dir
> >> produces  flow direction as 1-8 with 1 being North. R.water.outlet
> >> takes flow  direction input as 1-8 but I'm unsure of the if 1 is
> >> North. I suspect 1  is East but I'd appreciate any ideas.


for the record, here's some aspect map format information collected from
the help pages and source code:

(use d.rast.arrow and d.rast.num to investigate AGNPS, ANSWERS, GRASS
formats)


AGNPS (r.fill.dir)
category values from 1-8, with 1 facing north and increasing values in
the clockwise direction.


ANSWERS (r.fill.dir)
category values from 0-360 degrees, with 0 (360) facing east and values
increasing in the counter clockwise direction at 45 degree increments.


GRASS (r.fill.dir)
broken in 6.0.0. (was old GRASS 4? format) In the old days (pre-floating
point GRASS rasters) there was a 24-points based GRASS aspect map format
which still rears its ugly head sometimes:
24,1,2   east
3,4,5    north east
6,7,8    north
9,10,11  north west
12,13,14 west
15,16,17 south west
18,19,20 south
21,22,23 south east


GRASS (r.slope.aspect, others)
categories represent the number degrees of east and they increase
counterclockwise: 90deg is North, 180 is West, 270 is South and 360 is
East. Beware: 0 may be null! Similar to the ANSWERS format AFAICT.


r.param.scale
the direction of maximum gradient (considered downslope) is stored as
(West is 0 degree, East is +/- 180 degree):
 * 0..+180 degree from West to North to East
 * 0..-180 degree from West to South to East
[Anomaly: I vote for changing this to standard GRASS5 aspect format]


r.watershed drainage map (what r.water.outlet wants)
drainage direction. Provides the "aspect" for each cell. Multiplying
positive values by 45 will give the direction in degrees that the
surface runoff will travel from that cell. The value -1 indicates that
the cell is a depression area (defined by the depression input map).
Other negative values indicate that surface runoff is leaving the
boundaries of the current geographic region. The absolute value of these
negative cells indicates the direction of flow.
[should we change this to standard AGNPS(+neg flag) aspect format ??]


It would be nice to get these down to AGNPS, ANSWERS, and GRASS format
anyway.



so AGNPS is not the same as r.watershed format, but 45deg off:

dir AGNPS  r.watershed
N    1      0 or 8 ?
NE   2      1
E    3      2
SE   4      3
S    5      4
SW   6      5
W    7      6
NW   8      7


fix:

r.mapcalc 'aspect.watershed = if(aspect.AGNPS == 1, 8, \
  if(aspect.AGNPS > 1 && aspect.AGNPS <= 8, aspect.AGNPS-1, null() ))'


if that works we can add it to the help page. (looks ok to me)

note the negative values from the watershed program will be lost, which 
might adversely affect the output of r.water.outlet! (no idea)


> I did try r.terraflow initially but in this case r.fill.dir is much 
> faster because all I need is flow direction, not flow accumulation,
> TCI  or any of the other things r.terraflow provides.

ok

> Also, I was never able  to figure out how to get the flow direction
> r.water.outlet needs from  the r.terraflow flow direction (I was the
> guy that started that thread  you mentioned).

Oh sorry, only short term memory here.

FYI, I've whipped up a Matlab script to extract the dominant flow 
direction from the r.terraflow MFD output map and reclass it into
the GRASS aspect format for use with d.rast.arrow, etc. It should
be easy enough to rewrite it in something more Free and convert the
export into any of the above aspect formats by changing asp_mtx[].
Usually you can just use r.slope.aspect directly as a proxy.

find it here:
 http://grass.gdf-hannover.de/twiki/bin/view/GRASS/GrassAddOns


> Regardless of what I use to get flow direction it would  be helpful to
> know what format r.water.outlet  expects, ie what  direction  is 1
> North, East or something else.

AFAICT: 1 is NE, moving around the compass clockwise until 8 is North,
and mind the negative values and information lost by taking the absolute
value of flow direction.



Hamish




More information about the grass-user mailing list