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

Hamish hamish_b at yahoo.com
Tue Jul 21 04:53:59 EDT 2009


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



      



More information about the grass-user mailing list