[GRASS-user] slope along defined section (e.g. road, stream,)

Hamish hamish_b at yahoo.com
Wed Jun 25 09:18:56 EDT 2008


Konstanin:
> I am trying to get the profile (height) of a road network.
> I am following a similar idea than you, but have troubles to
> get it working (mainly because I have problems with the syntax
> of awk and grep). Maybe you could explain what happens in each
> line of your script so it is easier for me to understand ...

-----
#spearfish dataset
VMAP=railroads
QMAP=slope
OUT=rr_slope_points

v.out.ascii "$VMAP" format=standard | grep '^ [0-9]' | \
   grep -v ^' 1 ' | awk '{print $1 "," $2}' | \
   r.profile -g -c in="$QMAP" --quiet 2> /dev/null | \
   grep -v ' \* ' | cut -f1,2,4,5 -d' ' | \
   v.in.ascii x=1 y=2 out="$OUT" fs=space \
   columns='x double, y double, slope double, GRASSRGB varchar(11)'

   d.vect -a "$OUT" size=0 width=2

   (line vertices only; bug: includes profiles between line jumps...)
-----

# output lines in grass vector ascii format
v.out.ascii "$VMAP" format=standard | \

# find lines which start with a space, then a number (so no "L 12345")
   grep '^ [0-9]' | \

# find lines which do NOT start with a space then a 1 then another space
#  (ie category IDs)
   grep -v ^' 1 ' | \

# print the first and second numbers with a comma between them
   awk '{print $1 "," $2}' | \

# feed those coords into r.profile
   r.profile -g -c in="$QMAP" --quiet 2> /dev/null | \

# select lines in the profile which are NOT "*" (ie NULL data)
   grep -v ' \* ' | \

# take columns 1,2,4, and 5, using a space delimiter between columns
   cut -f1,2,4,5 -d' ' | \

# import that back in as a points map.
   v.in.ascii x=1 y=2 out="$OUT" fs=space \
   columns='x double, y double, slope double, GRASSRGB varchar(11)'



Hamish



      



More information about the grass-user mailing list