[GRASS-user] Re: IN: raster-flow-direction OUT:vector-network? (achim)

Hi Achim,

i usually produce the river network starting from the flow accumulation, not from the flow direction. If you have a raster elevation map you can get it using r.watershed.
Then, i make as follows:

r.mapcalc 'log_accumulation=log(abs(accumulation)+1)'

r.mapcalc 'inf_river=if(log_accumulation>6)'

6 is a treshold value for the log_accumulation, it is a good value for me but you maybe can try other values. It produces a binary map.

Then:

Raster -> Transform features -> Thin linear features to reduce at 1pixel the lines of the binary raster inf_river and create the new file in_river.
Finally, with r.to.vect you can transform the raster in_river in a vector map.

Hope this helps

Margherita

Message: 8
Date: Wed, 20 May 2009 16:45:56 +0200
From: achim <ak7@jupiter.uni-freiburg.de>
Subject: [GRASS-user] IN: raster-flow-direction OUT:vector-network?
To: grass-user <grass-user@lists.osgeo.org>
Message-ID: <4A1417A4.3040701@jupiter.uni-freiburg.de>
Content-Type: text/plain; charset="iso-8859-15"

Hello,

I am searching for a good idea to convert a raster-flow-direction map
into a vector-network map.

Probably I will have to write a script. If it is possible at all...

In case of writing a script it mean to me: how to produce a line within
r.mapcalc?

Has anyone a hint?

Cheers,
achim

PS:for illustration I attached a little picture
-------------- next part --------------
A non-text attachment was scrubbed...
Name: rasterflow-to-network.png
Type: image/png
Size: 5162 bytes
Desc: not available
Url : http://lists.osgeo.org/pipermail/grass-user/attachments/20090520/6198f353/rasterflow-to-network.png

------------------------------

_______________________________________________
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

End of grass-user Digest, Vol 37, Issue 35
******************************************

--
Ing. Margherita Di Leo
Ph.D. Student Methods and Technologies for Environmental Monitoring
Department of Environmental Engineering and Physics (DIFA)

University of Basilicata Campus Macchia Romana
85100 - Potenza Italy

Office: +39-0971205363
Fax: +39-0971205160
E-mail: dileomargherita AT gmail DOT com
Skype: dileomargherita
URL: http://www.difa.unibas.it/A_Manager_PP.do?azione=visualizzaHomePage&id=106

Thanks for reply,

but thats not exactly what I am searching for. I can not to use the
accumulation values, because

i) I want to figure out the watersheds on parts of the network
(beginning from certain points of the river network to separate some
basins on different levels; I already wrote a script to do it with the
direction raster map, but its slow and it does not allow me to do ii)

ii) I am going to do some statistics on stream lengths /accumulations on
network parts

iii) I need to separate parallel flowing streams from each other which
does not work on my current resolution

I start with pre-produced flow direction, accumulation...

Any workaround idea or scripting tips?

cheers again,
achim

PS: illustration on
http://lists.osgeo.org/pipermail/grass-user/attachments/20090520/6198f353/rasterflow-to-network.png

PPS:

r.mapcalc 'log_accumulation=log(abs(accumulation)+1)'

QUESTION:
why abs? accumulation values should be positive!?

Margherita Di Leo schrieb:

Hi Achim,

i usually produce the river network starting from the flow accumulation,
not from the flow direction. If you have a raster elevation map you can
get it using r.watershed.
Then, i make as follows:

r.mapcalc 'log_accumulation=log(abs(accumulation)+1)'

r.mapcalc 'inf_river=if(log_accumulation>6)'

6 is a treshold value for the log_accumulation, it is a good value for
me but you maybe can try other values. It produces a binary map.

Then:

Raster -> Transform features -> Thin linear features to reduce at 1pixel
the lines of the binary raster inf_river and create the new file in_river.
Finally, with r.to.vect you can transform the raster in_river in a
vector map.

Hope this helps

Margherita

Message: 8
Date: Wed, 20 May 2009 16:45:56 +0200
From: achim <ak7@jupiter.uni-freiburg.de>
Subject: [GRASS-user] IN: raster-flow-direction OUT:vector-network?
To: grass-user <grass-user@lists.osgeo.org>
Message-ID: <4A1417A4.3040701@jupiter.uni-freiburg.de>
Content-Type: text/plain; charset="iso-8859-15"

Hello,

I am searching for a good idea to convert a raster-flow-direction map
into a vector-network map.

Probably I will have to write a script. If it is possible at all...

In case of writing a script it mean to me: how to produce a line within
r.mapcalc?

Has anyone a hint?

Cheers,
achim

PS:for illustration I attached a little picture
-------------- next part --------------
A non-text attachment was scrubbed...
Name: rasterflow-to-network.png
Type: image/png
Size: 5162 bytes
Desc: not available
Url :
http://lists.osgeo.org/pipermail/grass-user/attachments/20090520/6198f353/rasterflow-to-network.png

------------------------------

_______________________________________________
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

End of grass-user Digest, Vol 37, Issue 35
******************************************

Hi there,

I don’t know how to help but I believe that Achim
have, for each pixel of stream, one value like 1, 2, 4, 8, 16, 32, 64 and 128,
and each of these values can be set to only one of 8 possible directions.

Milton
brazil=toronto

2009/5/20 achim <ak7@jupiter.uni-freiburg.de>

Thanks for reply,

but thats not exactly what I am searching for. I can not to use the
accumulation values, because

i) I want to figure out the watersheds on parts of the network
(beginning from certain points of the river network to separate some
basins on different levels; I already wrote a script to do it with the
direction raster map, but its slow and it does not allow me to do ii)

ii) I am going to do some statistics on stream lengths /accumulations on
network parts

iii) I need to separate parallel flowing streams from each other which
does not work on my current resolution

I start with pre-produced flow direction, accumulation…

Any workaround idea or scripting tips?

cheers again,
achim

PS: illustration on

http://lists.osgeo.org/pipermail/grass-user/attachments/20090520/6198f353/rasterflow-to-network.png

PPS:

r.mapcalc ‘log_accumulation=log(abs(accumulation)+1)’

QUESTION:
why abs? accumulation values should be positive!?

Margherita Di Leo schrieb:

Hi Achim,

i usually produce the river network starting from the flow accumulation,
not from the flow direction. If you have a raster elevation map you can
get it using r.watershed.
Then, i make as follows:

r.mapcalc ‘log_accumulation=log(abs(accumulation)+1)’

r.mapcalc ‘inf_river=if(log_accumulation>6)’

6 is a treshold value for the log_accumulation, it is a good value for
me but you maybe can try other values. It produces a binary map.

Then:

Raster → Transform features → Thin linear features to reduce at 1pixel
the lines of the binary raster inf_river and create the new file in_river.
Finally, with r.to.vect you can transform the raster in_river in a
vector map.

Hope this helps

Margherita

Message: 8
Date: Wed, 20 May 2009 16:45:56 +0200
From: achim <ak7@jupiter.uni-freiburg.de>
Subject: [GRASS-user] IN: raster-flow-direction OUT:vector-network?
To: grass-user <grass-user@lists.osgeo.org>
Message-ID: <4A1417A4.3040701@jupiter.uni-freiburg.de>
Content-Type: text/plain; charset=“iso-8859-15”

Hello,

I am searching for a good idea to convert a raster-flow-direction map
into a vector-network map.

Probably I will have to write a script. If it is possible at all…

In case of writing a script it mean to me: how to produce a line within
r.mapcalc?

Has anyone a hint?

Cheers,
achim

PS:for illustration I attached a little picture
-------------- next part --------------
A non-text attachment was scrubbed…
Name: rasterflow-to-network.png
Type: image/png
Size: 5162 bytes
Desc: not available
Url :
http://lists.osgeo.org/pipermail/grass-user/attachments/20090520/6198f353/rasterflow-to-network.png



grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

End of grass-user Digest, Vol 37, Issue 35



grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

achim wrote:

Thanks for reply,

but thats not exactly what I am searching for. I can not to use the
accumulation values, because

i) I want to figure out the watersheds on parts of the network
(beginning from certain points of the river network to separate some
basins on different levels;

r.water.outlet would do that, granted that flow direction has the same
format like r.watershed's flow direction

ii) I am going to do some statistics on stream lengths /accumulations on
network parts
  

Is the suggestion by Margherita Di Leo to get streams not working?

iii) I need to separate parallel flowing streams from each other which
does not work on my current resolution
  

I think v.generalize can separate parallel lines with method=displacement.

PPS:
  

r.mapcalc 'log_accumulation=log(abs(accumulation)+1)'
    

QUESTION:
why abs? accumulation values should be positive!?
  

Depends on the module used to create flow accumulation. r.watershed
produces negative flow accumulation values for areas where flow
accumulation is a likely underestimate (basin extending beyond region
extends or parts of the basin are masked out). Also see r.watershed manual.

The mapcalc approach may not work well on MFD accumulation maps; there
the stream output of r.watershed would help.

Markus M

Hi,

by the way, I solved my problem and want you to participate. If you are
interested in the script, just write back.

To get a network from a direction file I
- first made a raster file with a resolution tree times higher
- then I made eight raster files from this, one for each direction
- I added connecting, desired raster cells
- them r.to.vect
- and then I patched
(see attached picture)

Advantage in contrast to r.thin: even directly neighboring cells can be
considered. No little areas appearing and no shortcuts are made.

Hopefully helpfully for anyone,
Achim

PS: my directions
#
# 3 2 1
# 4 X 8
# 5 6 7
#

Markus GRASS schrieb:

achim wrote:

Thanks for reply,

but thats not exactly what I am searching for. I can not to use the
accumulation values, because

i) I want to figure out the watersheds on parts of the network
(beginning from certain points of the river network to separate some
basins on different levels;

r.water.outlet would do that, granted that flow direction has the same
format like r.watershed's flow direction

ii) I am going to do some statistics on stream lengths /accumulations on
network parts
  

Is the suggestion by Margherita Di Leo to get streams not working?

iii) I need to separate parallel flowing streams from each other which
does not work on my current resolution
  

I think v.generalize can separate parallel lines with method=displacement.

PPS:
  

r.mapcalc 'log_accumulation=log(abs(accumulation)+1)'
    

QUESTION:
why abs? accumulation values should be positive!?
  

Depends on the module used to create flow accumulation. r.watershed
produces negative flow accumulation values for areas where flow
accumulation is a likely underestimate (basin extending beyond region
extends or parts of the basin are masked out). Also see r.watershed manual.

The mapcalc approach may not work well on MFD accumulation maps; there
the stream output of r.watershed would help.

Markus M

(attachments)

network_directions.png