<div dir="ltr">Thank you Markus,<div><br></div><div>thats really a profound answer perfectly solving the problem. I've tested it, and</div><div>it is smoothly working in GRASS65. Just the variables for r.patch in python </div>
<div>are input and output instead of in and out....</div><div><br></div><div>cheers,</div><div>/johannes</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Jun 3, 2013 at 9:49 PM, Markus Metz <span dir="ltr"><<a href="mailto:markus.metz.giswork@gmail.com" target="_blank">markus.metz.giswork@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On Mon, Jun 3, 2013 at 3:30 PM, Johannes Radinger<br>
<<a href="mailto:johannesradinger@gmail.com">johannesradinger@gmail.com</a>> wrote:<br>
> Hi Markus,<br>
> Hi others,<br>
><br>
> I am coming back to the topic of running r.watershed on a rasterized river<br>
> network.<br>
><br>
> As recommended I buffered now my river raster. This river raster is a<br>
> thinned distance raster<br>
> with increasing values from the outlet to the branches (calculated via<br>
> r.cost) and as<br>
> I said it is buffered now with a very large value (2 x max of the thinned<br>
> distance raster).<br>
><br>
> So actually this should work as an input map to r.watershed. And it does<br>
> more or<br>
> less perfectly: There's just one issue concerning the outlet-stream segment.<br>
> Somehow this (in my case small segment, in the south-west corner) is missing<br>
> in the stream-map output of r.watershed.<br>
> I am working on GRASS6.5. Attached there is a zipped GTIFF with the<br>
> "pseudo-elevation" map<br>
> (this thinned and buffered distance raster) I am using as input to<br>
> r.watershed.<br>
<br>
</div>There is another error in the north-eastern part where a stream<br>
segment extents into the buffer area. The reason for these artefacts<br>
is that r.watershed does not know where the outlet is because all<br>
river segments are inside the buffer. In this case, the outlet is the<br>
starting point of r.cost which has in the river raster the value 0.<br>
You could produce the desired output with<br>
<br>
# buffer<br>
r.grow.distance input=river_raster value=river_raster_nearest<br>
<br>
# get value of nearest river cell<br>
r.grow input=river_raster output=river_raster_grow radius=2.01 old=1 new=100000<br>
<br>
# remove buffer for start point<br>
r.mapcalc "river_raster_grow_start = if(river_raster_nearest == 0,<br>
null(), river_raster_grow)"<br>
<br>
# grow by one cell to make sure that the start point is the only cell<br>
of the river bordering a NULL cell<br>
r.grow input=river_raster_grow_start output=river_raster_buffer<br>
radius=1.01 old=100000 new=100000<br>
<br>
# path river raster with buffer<br>
r.patch in=river_raster,river_raster_buffer out=buffered_distance_raster2<br>
<br>
# get stream segments<br>
r.watershed -s --overwrite elevation=buffered_distance_raster2<br>
stream=test_segments threshold=3<br>
<br>
HTH,<br>
<br>
Markus<br>
<div><div class="h5"><br>
><br>
> The command I am using is:<br>
> r.watershed -f --overwrite elevation=buffer_river_raster<br>
> stream=test_segments threshold=3<br>
> The threshold has been set to 3 as this is the number of raster cells that<br>
> refer to the buffer (3 x resolution)<br>
><br>
> Can anyone reproduce that the outlet small river segment is missing in the<br>
> produced "test_segments"??<br>
> What is causing that?<br>
><br>
> /Johannes<br>
><br>
><br>
><br>
><br>
><br>
> On Wed, Apr 10, 2013 at 12:37 PM, GRASS GIS <<a href="mailto:trac@osgeo.org">trac@osgeo.org</a>> wrote:<br>
>><br>
>> #1924: r.watershed - empty stream segment map<br>
>><br>
>> -----------------------+----------------------------------------------------<br>
>> Reporter: jradinger | Owner: grass-dev@…<br>
>> Type: defect | Status: new<br>
>> Priority: normal | Milestone:<br>
>> Component: Raster | Version: svn-trunk<br>
>> Keywords: | Platform: Linux<br>
>> Cpu: x86-32 |<br>
>><br>
>> -----------------------+----------------------------------------------------<br>
>><br>
>> Comment(by mmetz):<br>
>><br>
>> Replying to [comment:2 jradinger]:<br>
>> ><br>
>> > Two more important things:<br>
>> > 1) The elevation input map is accutally already a thinned river raster.<br>
>> The raster<br>
>> > values represent a pseude elevation which was generated with r.cost<br>
>> from the source.<br>
>> > Thus the value (elevation) is increasing upstream. r.watershed is just<br>
>> used for getting<br>
>> > the flowdirection and segmenting the river raster. (if needed I can<br>
>> provide the elevation-rcost<br>
>> > raster)<br>
>><br>
>> r.watershed expects a surface as input. Using a thinned river raster as<br>
>> input should give weird results: all non-NULL cells face at least one<br>
>> NULL<br>
>> cell treated as unknown elevation, thus flow direction can not be<br>
>> unambiguously determined. You can try to place a buffer around the rivers<br>
>> and fill the buffer with pseudo-elevation values larger than the largest<br>
>> cost value. For example, create a buffer using 300 meter (3 cells) as<br>
>> distance, set a pseudo elevation value for the buffer zone, patch the<br>
>> thinned river raster with the pseudo elevation, run r.watershed with<br>
>> threshold=3. Works for me.<br>
>><br>
>> > And maybe a warning/error message should be printed when threshold = 0,<br>
>> instead of the (for me confusing error)<br>
>><br>
>> Makes sense.<br>
>><br>
>> Markus M<br>
>><br>
>> --<br>
>> Ticket URL: <<a href="http://trac.osgeo.org/grass/ticket/1924#comment:3" target="_blank">http://trac.osgeo.org/grass/ticket/1924#comment:3</a>><br>
>> GRASS GIS <<a href="http://grass.osgeo.org" target="_blank">http://grass.osgeo.org</a>><br>
>><br>
><br>
><br>
</div></div>> _______________________________________________<br>
> grass-user mailing list<br>
> <a href="mailto:grass-user@lists.osgeo.org">grass-user@lists.osgeo.org</a><br>
> <a href="http://lists.osgeo.org/mailman/listinfo/grass-user" target="_blank">http://lists.osgeo.org/mailman/listinfo/grass-user</a><br>
><br>
</blockquote></div><br></div>