[GRASS5] r.profile

Dear all,
  
after toying around with the enhanced version of r.profile (great job, Bob!)
I
wonder if there's an _elegant_ way to pipe any output from v.out.ascii into
r.profile.
  
This is trivial for vectors consisting of just one line, but for multi-line
vectors
manual editing is still needed.
  
Cheers,
Peter

--
Dr. Peter Löwe

Diplom-Geograph

<loewe@geomancers.net>
<peter.loewe@gmx.de>

GMX DSL = Maximale Leistung zum minimalen Preis!
2000 MB nur 2,99, Flatrate ab 4,99 Euro/Monat: http://www.gmx.net/de/go/dsl

after toying around with the enhanced version of r.profile (great job,
Bob!) I wonder if there's an _elegant_ way to pipe any output from
v.out.ascii into r.profile.
  
This is trivial for vectors consisting of just one line, but for
multi-line vectors manual editing is still needed.

see the awk code in the v.in.garmin script.
(wrong direction, but may give you some ideas)

Hamish

after toying around with the enhanced version of r.profile (great job,
Bob!) I wonder if there's an _elegant_ way to pipe any output from
v.out.ascii into r.profile.
  
This is trivial for vectors consisting of just one line, but for
multi-line vectors manual editing is still needed.

I wouldn't call it elegant, but:

# lines to e1,n1,e2,n2[,...]
v.out.ascii multi_line format=standard | sed -e 1,10d | \
   grep -v ' 1 ' | tr '\n' ',' | sed -e 's/,L/\nL/g' | \
   cut -f2- -d',' | sed -e 's/^ //' | tr ' ' ',' | \
   sed -e 's/,$//' > ascii_lines.tmp

for LINE in `cat ascii_lines.tmp` ; do
   echo "$LINE" | r.profile -gc in=raster_map
done

I am sure awk would be prettier.

Hamish

> after toying around with the enhanced version of r.profile (great job,
> Bob!) I wonder if there's an _elegant_ way to pipe any output from
> v.out.ascii into r.profile.
>
> This is trivial for vectors consisting of just one line, but for
> multi-line vectors manual editing is still needed.

I wouldn't call it elegant, but:

# lines to e1,n1,e2,n2[,...]
v.out.ascii multi_line format=standard | sed -e 1,10d | \
   grep -v ' 1 ' | tr '\n' ',' | sed -e 's/,L/\nL/g' | \
   cut -f2- -d',' | sed -e 's/^ //' | tr ' ' ',' | \
   sed -e 's/,$//' > ascii_lines.tmp

for LINE in `cat ascii_lines.tmp` ; do
   echo "$LINE" | r.profile -gc in=raster_map
done

I am sure awk would be prettier.

Now that CVS is back I can test...

Correction: piping commas from stdin causes a segfault

v.out.ascii multi_line format=standard | sed -e 1,10d | \
    grep -v ' 1 ' | tr '\n' ',' | sed -e 's/,L/\nL/g' | \
    cut -f2- -d',' | sed -e 's/^ //' | tr ' ' ',' | \
    sed -e 's/,/,/g' | sed -e 's/,$//' > ascii_lines.tmp

g.region rast=raster_map
LINE_NUM=1
for LINE in `cat ascii_lines.tmp` ; do
   r.profile -gc in=raster_map profile=$LINE > line_${LINE_NUM}.prn
   LINE_NUM=$(($LINE_NUM + 1))
done

CVS updated to allow comma separated pairs from stdin, e.g.:
e1,n1
e2,n2
[...]
eN,nN

but

echo "e1,n1,e2,n2[,...,eN,nN] | r.profile

will still segfault.

Hamish

> > after toying around with the enhanced version of r.profile (great job,
> > Bob!) I wonder if there's an _elegant_ way to pipe any output from
> > v.out.ascii into r.profile.
> >
> > This is trivial for vectors consisting of just one line, but for
> > multi-line vectors manual editing is still needed.
>
> I wouldn't call it elegant, but:

...

v.out.ascii multi_line format=standard | sed -e 1,10d | \
    grep -v ' 1 ' | tr '\n' ',' | sed -e 's/,L/\nL/g' | \
    cut -f2- -d',' | sed -e 's/^ //' | tr ' ' ',' | \
    sed -e 's/,/,/g' | sed -e 's/,$//' > ascii_lines.tmp

g.region rast=raster_map
LINE_NUM=1
for LINE in `cat ascii_lines.tmp` ; do
   r.profile -gc in=raster_map profile=$LINE > line_${LINE_NUM}.prn
   LINE_NUM=$(($LINE_NUM + 1))
done

The next step is to pipe these into v.in.ascii points,

v.in.ascii in=line_1.prn out=line_1_pts fs=space \
  columns='x double, y double, distance double, value double, GRASSRGB varchar(11)'

...and display with fill color of the symbol taken from the new RGB
value (which was taken from the original raster map).

To do this we apply Martin Landa's d.vect GRASSRGB patch for lines
and points. (combined unidiff vs. latest CVS attached) see also:
  http://grass.itc.it/pipermail/grass5/2005-September/019563.html

Then plot with 'd.vect -a'. The results look quite nice. (see attached png)

[alternatively/comparatively use d.vect.thematic]

summary:

raster + vector line(s) + segmentation_distance

    => regularly spaced colored markers along track of line with
       colors taken from raster map. Use with d.legend.

e.g. plot some value along GPS track.

To finish this chain of tools we still need GRASSRGB support in ps.map,
... anyone?

Another idea is to use this to help visualize Radim's LRS,
  http://mpa.itc.it/radim/lrs/index.html
perhaps combined with a raster made with r.cost.

Hamish

(attachments)

d_vect_rgb_column.diff.gz (4.26 KB)
profile_rgb.png