[GRASSLIST:765] p.map.new & rast2gif (in GRASSLinks)

Dear GRASS Users:

I'trying to install GRASSLinks.

GRASSLinks has "rast2gif" command to convert map file to gif file.

rast2gif-----------------------------------------------------

#! /bin/sh
trap "/bin/rm -f $TMP_PATH/grasslinks.$$.ppm" 0 1 2 3 5 9 15

GIF=$1
GRASTER=$2
GVECTOR=$3
GSITES=$4
VCOLOR=$5
SCOLOR=$6
GIF_SIZE=$7
SCRIPT=$TMP_PATH/pmap_script.$$

touch $SCRIPT
p.select ppm > /dev/null 2>&1

if [ $GRASTER != "none" ]
then
        echo "raster $GRASTER" >> $SCRIPT
fi

if [ $GVECTOR != "none" ]
then
        echo "vector $GVECTOR" >> $SCRIPT
        echo " color $VCOLOR" >> $SCRIPT
        echo " end" >> $SCRIPT
fi

if [ $GSITES != "none" ]
then
        echo "sites $GSITES" >> $SCRIPT
        echo " color $SCOLOR" >> $SCRIPT
        echo " end" >> $SCRIPT
fi

echo "end" >> $SCRIPT

p.map.new input=$SCRIPT > /dev/null 2>&1

case $GIF_SIZE in
    large) MAX_RES=800 ;;
    medium) MAX_RES=400 ;;
    small) MAX_RES=200 ;;
esac

( $PBM_PATH/pnmscale -xysize $MAX_RES $MAX_RES < $MAPLP | $PBM_PATH/ppmquant 256
| $PBM_PATH/ppmtogif > $TMP_PATH/$GIF ) 2> /dev/null

-------------------------------------------------------------------

The first half of this script works,(to echo "end" >> $SCRIPT )
Because this script makes "$SCRIPT" file.
But "p.map.new" command can't make ppm file.
Why can't "p.map.new" command make ppm file?

Please give me your suggestion.

And I have some questions.
1) "p.map.new" command demands parameter "GISBASE" and "GISRC".
    How does GRASSLinks read these parameter?

2) In this script, Which does p.map.new use ppm driver?

Glynn Clements wrote:

I think that the PPM driver is disabled by default. Try copying the
file etc/paint/driver.uninst/ppm to etc/paint/driver.sh/ppm.

GRASS has already have PPM driver in /*/grass/etc/paint/driver.sh/ppm .
On the other hand, GRASSLinks has PPM driver in /home/grass/grasslinks/paint/dreiver.sh/ppm .
Which does p.map.new use ppm driver?

Please give me your advise.
Thank you in advance.
Sincerely yours.

Hi,

If your GRASSLINKS can create pmap_script.$$ but can't create gif,
you need to check the followings are correct:

1. if p.map.new generates ppm file. p.map.new will create a
file named paint.ppm. And the direcotry of paint.ppm is defined
in grass5/etc/paint/driver.sh/ppm by MAPLP.

2. if ppmtogif works. ppmtogif is a tool of unix/lunix. It read
the paiint.ppm and convert it into gif. So, please make sure
setup for directory is correct.

The setup for GISBASE and GISDBASE is done in one of GRASSLINKS
funtion.

Regards,

Xueming

On Mon, 21 Jul 2003, Hayashi Shin-ichiro wrote:

Dear GRASS Users:

I'trying to install GRASSLinks.

GRASSLinks has "rast2gif" command to convert map file to gif file.

rast2gif-----------------------------------------------------

#! /bin/sh
trap "/bin/rm -f $TMP_PATH/grasslinks.$$.ppm" 0 1 2 3 5 9 15

GIF=$1
GRASTER=$2
GVECTOR=$3
GSITES=$4
VCOLOR=$5
SCOLOR=$6
GIF_SIZE=$7
SCRIPT=$TMP_PATH/pmap_script.$$

touch $SCRIPT
p.select ppm > /dev/null 2>&1

if [ $GRASTER != "none" ]
then
        echo "raster $GRASTER" >> $SCRIPT
fi

if [ $GVECTOR != "none" ]
then
        echo "vector $GVECTOR" >> $SCRIPT
        echo " color $VCOLOR" >> $SCRIPT
        echo " end" >> $SCRIPT
fi

if [ $GSITES != "none" ]
then
        echo "sites $GSITES" >> $SCRIPT
        echo " color $SCOLOR" >> $SCRIPT
        echo " end" >> $SCRIPT
fi

echo "end" >> $SCRIPT

p.map.new input=$SCRIPT > /dev/null 2>&1

case $GIF_SIZE in
    large) MAX_RES=800 ;;
    medium) MAX_RES=400 ;;
    small) MAX_RES=200 ;;
esac

( $PBM_PATH/pnmscale -xysize $MAX_RES $MAX_RES < $MAPLP | $PBM_PATH/ppmquant 256
| $PBM_PATH/ppmtogif > $TMP_PATH/$GIF ) 2> /dev/null

-------------------------------------------------------------------

The first half of this script works,(to echo "end" >> $SCRIPT )
Because this script makes "$SCRIPT" file.
But "p.map.new" command can't make ppm file.
Why can't "p.map.new" command make ppm file?

Please give me your suggestion.

And I have some questions.
1) "p.map.new" command demands parameter "GISBASE" and "GISRC".
    How does GRASSLinks read these parameter?

2) In this script, Which does p.map.new use ppm driver?

Glynn Clements wrote:
>I think that the PPM driver is disabled by default. Try copying the
>file etc/paint/driver.uninst/ppm to etc/paint/driver.sh/ppm.

GRASS has already have PPM driver in /*/grass/etc/paint/driver.sh/ppm .
On the other hand, GRASSLinks has PPM driver in /home/grass/grasslinks/paint/dreiver.sh/ppm .
Which does p.map.new use ppm driver?

Please give me your advise.
Thank you in advance.
Sincerely yours.

2. if ppmtogif works. ppmtogif is a tool of unix/lunix. It read
the paiint.ppm and convert it into gif. So, please make sure
setup for directory is correct.

More precisely it is an ImageMagick tool, and runs on all Unix/Windows/Mac.
http://www.imagemagick.org

You might also want to try the GRASS PNG Driver or X window dump.
Another approach is ps.map to pstopnm|pnmtopng if you prefer.

Here are some Bash scripts for making PNG hardcopies of a GRASS monitor--

d.out.png.xwd:
#!/bin/sh
# WYSIWYG but not double buffered
if [ -z $GISBASE ] ; then
        echo "You have to be in GRASS to use this."
        exit
fi
if [ -z "$1" ] ; then
        echo "USAGE: d.out.png PNGfilename (.png added automatically)"
        echo " Make a PNG hardcopy of a GRASS monitor"
        exit
else
        OLD_MON=`d.mon -p | awk '{printf "%s", $4}'`
        GRASS_VER=`g.version | awk '{printf "%s", $1 " " $2}'`
        export GRASS_PNGFILE="$1".png
        echo "Exporting to $GRASS_PNGFILE from [$GRASS_VER- Monitor: $OLD_MON]"
        xwd -name "$GRASS_VER- Monitor: $OLD_MON" | xwdtopnm | pnmtopng > $GRASS_PNGFILE
fi

===

d.out.png.driver:
#!/bin/sh
# double buffered but not WYSIWYG
if [ -z $GISBASE ] ; then
        echo "You have to be in GRASS to use this."
        exit
fi
if [ -z "$1" ] ; then
        echo "USAGE: d.out.png PNGfilename (.png added automatically)"
        echo " Make a PNG hardcopy of a GRASS monitor"
        exit
else
        OLD_MON=`d.mon -p | awk '{printf "%s", $4}'`
        GRASS_VER=`g.version | awk '{printf "%s", $1 " " $2}'`
        export GRASS_PNGFILE="$1".png
        echo "Exporting to $GRASS_PNGFILE from [$GRASS_VER- Monitor: $OLD_MON]"
        xwininfo -name "$GRASS_VER- Monitor: $OLD_MON" > /tmp/GRASS.wininfo.$$
        export GRASS_WIDTH=`grep Width /tmp/GRASS.wininfo.$$ | awk '{printf "%d", $2}'`
        export GRASS_HEIGHT=`grep Height /tmp/GRASS.wininfo.$$ | awk '{printf "%d", $2}'`
        rm -f /tmp/GRASS.wininfo.$$
# export GRASS_TRUECOLOR=TRUE # with GD-2.0
        d.save -c > /tmp/GRASS_pngmap.$$
        d.mon start=PNG
        d.mon select=PNG
        . /tmp/GRASS_pngmap.$$
        d.mon stop=PNG
        echo "Processed monitor "$OLD_MON" ["$GRASS_WIDTH"x$GRASS_HEIGHT] to $GRASS_PNGFILE"
        rm -f /tmp/GRASS_pngmap.$$
        d.mon select=$OLD_MON
        sleep 1 # wait for file to finish writing
# eeyes "$1".png &
fi

===
Hamish

H Bowman wrote:

> 2. if ppmtogif works. ppmtogif is a tool of unix/lunix. It read
> the paiint.ppm and convert it into gif. So, please make sure
> setup for directory is correct.

More precisely it is an ImageMagick tool, and runs on all Unix/Windows/Mac.
http://www.imagemagick.org

Actually, ppmtogif is a NetPBM utility. More generally, most programs
with "pbm", "pgm", "ppm" or "pnm" in their names are NetPBM utilites.

ImageMagick has the "convert" program for converting between different
image formats.

--
Glynn Clements <glynn.clements@virgin.net>