[GRASS-user] What to do with the output of v.strahler? Coloring a stream vector.

I would like to use the stream orders to color the stream vectors.
How would I go about doing this? My thought is to make the stream
vector into a raster after I have attached the stream orders based on
a common identifier (line?). There are some zero order streams, which
I don't understand. Any ideas would be greatly appreciated. My
thought is to use R to do the merging, but this is a half backed idea
right now. Thanks for any help.

--
Stephen Sefick

Let's not spend our time and resources thinking about things that are
so little or so large that all they really do for us is puff us up and
make us feel like gods. We are mammals, and have not exhausted the
annoying little problems of being mammals.

                -K. Mullis

stephen sefick wrote:

I would like to use the stream orders to color the stream vectors.
How would I go about doing this?

If using a recent version of grass use the v.colors script.

It acts like r.colors but uploads RGB values to a DB column, typically
called "GRASSRGB".

Then use 'd.vect -a' (or GUI equivalent) to render using those rules.

My thought is to make the stream vector into a raster after I have
attached the stream orders based on a common identifier (line?).

....

My thought is to use R to do the merging, but this is a half
backed idea right now.

v.net modules can isolate connected paths, search archives and help pages
for examples. r.cost is another way to do that.

Hamish

Hamish et al.,
The problem that I am having is that the output of v.strahler writes
its results to a text file. I don't know how to merge this into a
vector called stream order. I will look into your sugesstions, but I
don't knw if I understand them.
kind regards,

Stephen Sefick

On Sun, Jul 12, 2009 at 12:57 AM, Hamish<hamish_b@yahoo.com> wrote:

stephen sefick wrote:

I would like to use the stream orders to color the stream vectors.
How would I go about doing this?

If using a recent version of grass use the v.colors script.

It acts like r.colors but uploads RGB values to a DB column, typically
called "GRASSRGB".

Then use 'd.vect -a' (or GUI equivalent) to render using those rules.

My thought is to make the stream vector into a raster after I have
attached the stream orders based on a common identifier (line?).

....

My thought is to use R to do the merging, but this is a half
backed idea right now.

v.net modules can isolate connected paths, search archives and help pages
for examples. r.cost is another way to do that.

Hamish

--
Stephen Sefick

Let's not spend our time and resources thinking about things that are
so little or so large that all they really do for us is puff us up and
make us feel like gods. We are mammals, and have not exhausted the
annoying little problems of being mammals.

                -K. Mullis

stephen sefick wrote:

I would like to use the stream orders to color the stream vectors.
How would I go about doing this?

it's actually quite easy, as v.strahler uses order as the output map's cat
order.

here is a spearfish dataset example:

#spearfish dataset
g.region rast=elevation.dem

r.watershed elev=elevation.dem stream=rwater.stream threshold=100
# (see also r.watershed help page for creating river map from accumulation output)
r.to.vect -v in=rwater.stream out=rwater_stream
d.vect -c rwater_stream

v.strahler in=rwater_stream out=strahler_stream dem=elevation.dem \
   txout=strahler.out

# category is Order
d.vect strahler_stream cat=0 color=black width=2
d.vect strahler_stream cat=1 color=grey

# store colors for later use with d.vect -a
v.db.addtable strahler_stream columns='GRASSRGB varchar(11)'
v.db.update strahler_stream where='cat = 0' value='0:0:0' column=GRASSRGB
v.db.update strahler_stream where='cat = 1' value='100:100:100' column=GRASSRGB
v.db.update strahler_stream where='cat = 2' value='160:160:160' column=GRASSRGB
d.vect -a strahler_stream

.... it would perhaps be better if v.strahler used unique feature ID
(the Line column in the ascii output table) as cat instead of order
then populated a DB instead of writing to text file table.

if only cat was changed to use feature (Line) instead of Order in
the source code, you could then do:

# use text output of v.strahler to add attributes to input river map
v.db.addcol strahler_stream \
  columns='rwater_cat integer, stlr_basin integer, stlr_order integer, GRASSRGB varchar(11)'

cat strahler.out | sed -e '1,2d' | \
  awk '{printf("UPDATE strahler_stream SET stlr_cat=%d,stlr_basin=%d,stlr_order=%d WHERE cat = %d;\n", $1, $3, $4, $2)}' \
  > strahler.sql

db.execute in=strahler.sql

[ to do that looks as simple as adjusting this line in main.c
   Vect_cat_set(Cats, field, dbbuf[line].sorder);

(change dbbuf[line].sorder to be dbbuf[line].line) ]

good luck,
Hamish