[GRASS-user] Re: negative accumulation with r.watershed in GRASS 7

Markus Metz markus.metz.giswork at googlemail.com
Fri Nov 25 15:05:03 EST 2011


Pankaj Kr Sharma wrote:
> Dear Grass users and developers,
>
> The run-time messages of command r.watershed is pasted below.
> This I ran as per suggestions on a threshold area of 100 sq km. Considerable

Be aware that the threshold option of r.watershed does not refer to
catchment area (basin) size but to stream initiation. That means that
a stream is started if the surface flow accumulation reaches the
threshold value. All all upstream cells have consequently a flow
accumulation value lower than the threshold value. That means also
that exterior basins are larger than <threshold value> because
catchments (basins) are calculated from the last confluence upstream
which has necessarily a flow accumulation value larger than
<threshold>. That also means that the attempt to identify basins of a
fixed size does not make sense from a hydrological perspective because
basins are more realistically defined upstream of a point of
confluence (which in turn is dependent of the threshold value), i.e.
the catchment areas of the tributaries joining at a given point of
confluence. This in turn means that interior basins can have a size
from 1 to <threshold>

> number of basins  are in the limit 1 to 100 sq km. The results represent are
> close to natural distribution of watersheds. However, from the results, it
> appears to me that the threshold limit should be considered only as a
> guideline and not to find basins of size larger than the threshold limit.
> (Thu Nov 24 17:07:28
> 2011)
> r.watershed elevation=ybdem at work threshold=12345
> accumulation=ybdem100sqkm_acc drainage=ybdem100sqkm_fdir
> basin=ybdem100sqkm_basin stream=ybdem100sqkm_stream
> SECTION 1a (of 5): Initiating Memory.
> SECTION 1b (of 5): Determining Offmap Flow.
> SECTION 2: A* Search.
> SECTION 3: Accumulating Surface Flow with MFD.
> SECTION 4: Watershed determination.
> SECTION 5: Closing Maps.
> (Thu Nov 24 17:09:38 2011) Command finished (130 sec)
>
> -----------------------------------------------------------------------------------------------------------------------------
>
> In this part, I tried to ran r.watershed with SFD flag.
>
> (Thu Nov 24 17:21:40
> 2011)
> r.watershed -s elevation=ybdem at work threshold=12345
> accumulation=ybdem100sqkm_acc_sfd drainage=ybdem100sqkm_fdir_sfd
> basin=ybdem100sqkm_basin_sfd stream=ybdem100sqkm_stream_sfd
> SECTION 1a (of 5): Initiating Memory.
> SECTION 1b (of 5): Determining Offmap Flow.
> SECTION 2: A* Search.
> SECTION 3: Accumulating Surface Flow with SFD.
> SECTION 4: Watershed determination.
> Subprocess failed with exit code 9
> category information for [ybdem100sqkm_acc_sfd] in [work] missing or invalid
> category information for [ybdem100sqkm_fdir_sfd] in [work] missing or
> invalid
> category information for [ybdem100sqkm_basin_sfd] in [work] missing or
> invalid
> category information for [ybdem100sqkm_stream_sfd] in [work] missing or
> invalid
> (Fri Nov 25 09:46:01 2011) Command finished (59061 sec)
>
> One can see that I had manually terminated the command from "system
> monitor". It didn't complete.
> I tried again.
>
> (Fri Nov 25 09:46:35
> 2011)
> r.watershed -s --overwrite elevation=ybdem at work threshold=12345
> accumulation=ybdem100sqkm_acc_sfd drainage=ybdem100sqkm_fdir_sfd
> basin=ybdem100sqkm_basin_sfd stream=ybdem100sqkm_stream_sfd
> SECTION 1a (of 5): Initiating Memory.
> SECTION 1b (of 5): Determining Offmap Flow.
> SECTION 2: A* Search.
> SECTION 3: Accumulating Surface Flow with SFD.
> SECTION 4: Watershed determination.
> Please note that the data are left in inconsistent state and may be
> corrupted
> (Fri Nov 25 10:23:45 2011) Command aborted (2230 sec)
>
> It wasn't working. I found in "system monitor" that the program
> r.watershed.ram is using only 2gb ram.
> The issue may be of interest to GRASS developers.
> So, I tried again with "memory" mode and it worked.
>
> (Fri Nov 25 10:24:33
> 2011)
> r.watershed -s -m --overwrite elevation=ybdem at work threshold=12345
> accumulation=ybdem100sqkm_acc_sfd drainage=ybdem100sqkm_fdir_sfd
> basin=ybdem100sqkm_basin_sfd stream=ybdem100sqkm_stream_sfd memory=12000
> SECTION 1 beginning: Initiating Variables. 5 sections total.
> SECTION 1a: Mark masked and NULL cells
> SECTION 1b: Determining Offmap Flow.
> SECTION 2: A* Search.
> SECTION 3: Accumulating Surface Flow with SFD.
> SECTION 4: Watershed determination.
> SECTION 5: Closing Maps.
> Closing stream segments map
> Closing basins map
> Closing accumulation map
> Closing flow direction map
> (Fri Nov 25 10:28:46 2011) Command finished (252 sec)

I would like to test why it does not work with the all-in-memory mode.
Unfortunately, I was not able to reproduce it with the GRASS sample
datasets. Could you provide a link to the DEM in question? Thanks!
>
> It was suggested that from the accumulation values equal to the number of
> cells of area required (i.e. 12345 for 100 sq km), one can find tentative
> points having watershed equal to the area desired.
> In the accumulation values , I found that there is no value near 12345. And

As mentioned above, this does not make sense. Imagine two streams of
upstream catchment areas of 12344 joining at a confluence. The next
cell will have a surface flow accumulation value of 2 * 12344 which is
larger than 12345. Same principle for two streams joining, one with
12344, the other with 2. You get the idea.

> there are lot of negative values.
>
[snip]
>
> I have read that negative values mean that area getting flow outside the
> current region.
> That's simply not possible in my case. I have created this basin from
> r.water.outlet. I used that as mask to cut the DEM of only that area.

This is to be expected because an upstream catchment area (basin) is
defined such that all neighboring cells (cells just outside the
catchment area) do not contribute to the basin in question. This can
obviously only be determined if the elevation of these neighboring
cells is known. If the elevation of these neighboring cells is unknown
(in your case MASK'ed), it must be assumed that some unknown amount of
surface flow from these neighboring cells pours into the basin of
question. The solution is to grow the MASK by at least one cell,
better two cells. The objective is to have all cells that are adjacent
to the basin in question un-MASK'ed (the other way around: the basin
in question must not be bordered by NULL cells that are not NULL cells
in the original DEM). Only then run r.watershed. This will give you
only positive accumulation values for the basin in question (granted
that the basin is surrounded by elevation values that are not NULL).
>
> Can anyone please shed some more light on it. Or share their experiences
> with us in this regard.
> Basically, I have two queries now. 1. How to get positive accumulation
> values. 2. How to find the accumulation value representing 100 sq km basin
> area.

About the accumulation value representing 100 sq km basin: from a
hydrological perspective, it does not make sense IMHO. Why do you want
to identify basins of a fixed size?

Markus M

PS: for the time being, you will have to use grass7 in text mode
because the GUI is not working.


More information about the grass-user mailing list