[GRASS-dev] Streams extraction from streams map

Hi,

I have a network of streams (say, Spearfish or better the new
NC data set at http://mpa.itc.it/grasstutor/data_menu3rd.phtml )
and want to extract a single stream system. Names are lacking,
is there any trick to extract topologically connected lines
into a new map?

Markus

On Tue, May 01, 2007 at 12:37:15PM +0200, Markus Neteler wrote:

Hi,

I have a network of streams (say, Spearfish or better the new
NC data set at http://mpa.itc.it/grasstutor/data_menu3rd.phtml )
and want to extract a single stream system. Names are lacking,
is there any trick to extract topologically connected lines
into a new map?

Probably we need some equivalent to the "sides" operator in
v.to.db (which tells you the cats of the left and right polygon).
Some magic which finds the lines which are connected and writes
out some related attribute(s).

Ideas welcome,
Markus

Markus Neteler wrote:

> I have a network of streams (say, Spearfish or better the new
> NC data set at http://mpa.itc.it/grasstutor/data_menu3rd.phtml )
> and want to extract a single stream system. Names are lacking,
> is there any trick to extract topologically connected lines
> into a new map?

Probably we need some equivalent to the "sides" operator in
v.to.db (which tells you the cats of the left and right polygon).
Some magic which finds the lines which are connected and writes
out some related attribute(s).

how about v.net.iso? disconnected networks will have infinite cost.

!,
Hamish

Markus,

I remember that someone recently wrote a module that will calculate stream
Strahler order. This may well have code that you can use for this task,
since it must calculate whether or not a stream segment has 'tributaries'. I
think that it's posted somewhere--WIKI, Grassaddons, ?

Michael

On 5/2/07 2:04 AM, "Markus Neteler" <neteler@itc.it> wrote:

On Tue, May 01, 2007 at 12:37:15PM +0200, Markus Neteler wrote:

Hi,

I have a network of streams (say, Spearfish or better the new
NC data set at http://mpa.itc.it/grasstutor/data_menu3rd.phtml )
and want to extract a single stream system. Names are lacking,
is there any trick to extract topologically connected lines
into a new map?

Probably we need some equivalent to the "sides" operator in
v.to.db (which tells you the cats of the left and right polygon).
Some magic which finds the lines which are connected and writes
out some related attribute(s).

Ideas welcome,
Markus

__________________________________________
Michael Barton, Professor of Anthropology
School of Human Evolution & Social Change
Center for Social Dynamics & Complexity
Arizona State University

phone: 480-965-6213
fax: 480-965-7671
www: http://www.public.asu.edu/~cmbarton

On Wed, May 02, 2007 at 08:05:40AM -0700, Michael Barton wrote:

Markus,

I remember that someone recently wrote a module that will calculate stream
Strahler order. This may well have code that you can use for this task,
since it must calculate whether or not a stream segment has 'tributaries'. I
think that it's posted somewhere--WIKI, Grassaddons, ?

I tried this v.strahler recently but it didn't work (it is in the GRASS
Addons SVN) - for me. Maybe it's still under development. But yes,
this would probably do the job.

Markus

On May 02 [17:12], Markus Neteler wrote:

I tried this v.strahler recently but it didn't work (it is in the GRASS
Addons SVN) - for me. Maybe it's still under development. But yes,
this would probably do the job.

Hi,
Yes, v.strahler assigns a common identifier to all connected segments.
The code is in forest2tree.c:
StrahForestToTrees() makes use of Vect_get_line_nodes() and
Vect_get_node_line() to accomplish this.

Hints on why the code fails are more than welcome.

A word on why Vect_get_node_line() is hidden in StrahGetNodeLine():
I tried to implement "sloppy" mode where lines need not connect in a
topologically correct way but merely share nodes within a certain distance.
However, this adds a lot of complexity and isn't the point of v.strahler
at all (better run v.clean instead) - so it's defunct for now.

As far as the module "is still under development": well, it should be,
but for the moment I don't find the time. Feel free to hack on the
code if you have a good idea.

\flo

--
Florian Kindl
Institute of Geography
University of Innsbruck

On Wed, May 02, 2007 at 11:35:10PM +1200, Hamish wrote:

Markus Neteler wrote:
> > I have a network of streams (say, Spearfish or better the new
> > NC data set at http://mpa.itc.it/grasstutor/data_menu3rd.phtml )
> > and want to extract a single stream system. Names are lacking,
> > is there any trick to extract topologically connected lines
> > into a new map?
>
> Probably we need some equivalent to the "sides" operator in
> v.to.db (which tells you the cats of the left and right polygon).
> Some magic which finds the lines which are connected and writes
> out some related attribute(s).

how about v.net.iso? disconnected networks will have infinite cost.

Wow - that works!

Spearfish example:

d.vect streams disp=shape,dir
d.where
g.copy vect=streams,mystreams

echo "602042|4927928" | v.in.ascii out=outlet --o
v.distance -p from=outlet to=mystreams out=connect upload=dist column=dist --o

v.patch in=mystreams,connect,outlet out=streams_n --o
v.clean streams_n out=streams_net tool=snap,break thresh=5,0 --o

g.region vect=streams_net
d.erase
d.vect streams_net
d.vect streams_net type=point col=red icon=basic/triangle

v.net.iso streams_net out=myriver ccats=1 costs=99999999 nlayer=1 --o

v.category myriver option=report
# The network is of 2 categories
# show selected river network
d.vect myriver col=blue cats=1
d.vect myriver col=green cats=2

# now v.extract etc ...

Note that some upper parts of the river network are not found due to
unconnected lines.

Thanks for the hint,
Markus