[GRASS5] r.profile
Hamish
hamish_nospam at yahoo.com
Wed Sep 28 05:14:51 EDT 2005
> > 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
More information about the grass-dev
mailing list