SUM: GRASS to GMT

I just wanted to let people know that outputting GRASS
raster files into GMT format was fairly straight
forward with Stephan Eickschen's script. The only
problem I had was with r.stats and the -m switch which
does not appear to be working with GRASS5beta8, I
haven't tested this yet so more to come. Also, note
the behavior of the script with respect to zero
values, as written it pulls them out of the output
stream.

If there is enough interest, I would be willing to
flush this out a bit in perl so that colormaps are
translated as well as setting up a lat/long graticule
and neatline in GMT. (this is a bit tricky if your
raster is already projected)

In general though, GMT is a powerful alternative to
GRASS's native postscript options and is worth a look
if you can't get GRASS to produce what you need.

To use the script type: ./grass2gmt.sh <raster>

--- grass2gmt.sh script: ---

#!/bin/csh -f

g.region -g >! tmp.tmp

#
# the following lines could be simplfied if g.region
enables a
# one line output - a single awk line would create
$reg $inc
#

set N=`grep ^n= tmp.tmp | cut -f 2 -d "="`
set S=`grep ^s= tmp.tmp | cut -f 2 -d "="`
set E=`grep ^e= tmp.tmp | cut -f 2 -d "="`
set W=`grep ^w= tmp.tmp | cut -f 2 -d "="`
set NSRES=`grep ^nsres tmp.tmp | cut -f 2 -d "="`
set EWRES=`grep ^ewres tmp.tmp | cut -f 2 -d "="`

r.stats -1xmg $1 |\
  awk '{ if($5!=0) print $1, $2, $5 }' |\
  xyz2grd -G$1.grd -I$EWRES/$NSRES -R$W/$E/$S/$N -V -F

# below here are GMT commands to plot the file into
map.ps

set X=`echo $N $S $NSRES $E $W $EWRES | awk '{ print
($4-$5)/$6/(($1-$2)/$3)*2 '`

grd2cpt $1.grd >! $1.cpt
grdimage -JX$X/2 $1.grd -C$1.cpt -Y4 -V >> map.ps

=====
--
David Finlayson
david_finlayson@yahoo.com
University of Washington
Box 351310
Seattle, WA 98195 - 1310

__________________________________________________
Do You Yahoo!?
Yahoo! Messenger - Talk while you surf! It's FREE.
http://im.yahoo.com/