[GRASS-dev] Wrong direction in r.watershed slope length calculation?

Markus Metz markus.metz.giswork at gmail.com
Mon Apr 8 08:02:55 PDT 2013


On Mon, Apr 8, 2013 at 11:44 AM,  <josten at abo.fi> wrote:
> I discovered the following in r.watershed/ram/slope_len.c where the slope
> length is calculated given two cell positions in the raster.
>
> if (r == dr)
>     res = window.ns_res;
> else if (c == dc)
>     res = window.ew_res;
> else
>     res = diag;
>
> Here we are dealing with a cell given by coordinates (r,c) which flows into
> another cell (dr,dc). So the code reads to me that if the two cells are on
> the same row, add to the slope the map's North-South resolution. Should it
> not be West-East since the slope is horizontal rather than vertical and vice
> versa for the columns?

yes

>
> This seems like a bug to me and the code is taken from the latest snapshot.

This bug has been present ever since (GRASS 4.0). Fixed in trunk r55666.

Markus M


More information about the grass-dev mailing list