Streams extraction from streams map

From GRASS-Wiki
Revision as of 20:36, 5 June 2009 by Neteler (talk | contribs) (new)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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

A: Use v.net.iso since disconnected networks will have infinite cost.

Spearfish example:

g.region vect=streams
d.mon 0
d.vect streams disp=shape,dir

# find coordinates
d.where

# work on map copy
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.