zoom in/out?

Lars Schylberg larss at fmi.kth.se
Tue Jun 1 11:40:21 EDT 1993


I wrote this little shell script last year.  I isn't the nicest solution
but could be something to use if you don't intend to start to program. 
I also wish that the zooming function from v.digit could be lifted out.

Lars

Lars Schylberg                          Email: larss at fmi.kth.se  
Dept. of Geodesy and Photogrammetry 
Royal Institute of Technology (KTH)     Tel.   +46 8 790 86 33   
S-100 44  STOCKHOLM, SWEDEN             Fax.   +46 8 790 66 10

----------------------------- cut here -----------------------------

#!/bin/sh
#
#  d.zoom_out.sh
#
#  Author: Lars Schylberg
#  email: larss at fmi.kht.se
#  
#  Date 920703
#
#------------------------------------------------------------------------
# Check if GRASS is running
#
test "$GISRC" || echo "GRASS is not running" || exit 2
#----------------------------------------------------------------------------
#
#  Evaluate arguments
#
if [ $# != 2 ]
then
    echo
    echo Usage: `basename $0` 
    echo '       map=mapname '
    echo '       visual=yes|no '
    echo
    exit 1
fi
#
#  parse input arguments
#
for i do
	case $i in
		map=*)
			MAP=`echo $i | sed s/map=//` ;;
		visual=*)
			VIS=`echo $i | sed s/visual=//` ;;
		*)
			echo ""
			echo "Unrecognized option: $i"
			echo 'Options: map=mapname '
			echo '         visual=yes|no '
                        echo ""
			exit 1
	esac
done
#-------------------------------------------------------------------------
#
TMP=tmp.`basename $0`.$$
#
# Get the categories max and min coordinates
#
g.region -p | sed "s/\..*//" > $TMP
#
N=`grep north $TMP | sed "s/[^0-9]*//"`
S=`grep south $TMP | sed "s/[^0-9]*//"`
E=`grep east $TMP | sed "s/[^0-9]*//"`
W=`grep west $TMP | sed "s/[^0-9]*//"`
#
#  Determine current resolution to place a border
#  that equals the currently shown display
#
NSRES=`grep nsres $TMP | sed "s/[^0-9]*//"`
EWRES=`grep ewres $TMP | sed "s/[^0-9]*//"`
/bin/rm $TMP
#
NSBORDER=`expr $N - $S`
EWBORDER=`expr $E - $W`
north=`expr $N + $NSBORDER`
south=`expr $S - $NSBORDER`
east=`expr $E + $EWBORDER`
west=`expr $W - $EWBORDER`
#
#  Check that the new region not is outside the default region
#
g.region -dp | sed "s/\..*//" > $TMP
DN=`grep north $TMP | sed "s/[^0-9]*//"`
DS=`grep south $TMP | sed "s/[^0-9]*//"`
DE=`grep east $TMP | sed "s/[^0-9]*//"`
DW=`grep west $TMP | sed "s/[^0-9]*//"`
/bin/rm $TMP
#
if [ $north -gt $DN ]; then
north=$DN
fi
if [ $south -lt $DS ]; then
south=$DS
fi
if [ $east -gt $DE ]; then
east=$DE
fi
if [ $west -lt $DW ]; then
west=$DW
fi
#
#  Set the new region
#
g.region n=$north s=$south e=$east w=$west nsres=$NSRES ewres=$EWRES
#
if [ $VIS = yes ] ; then
  d.erase
  d.rast $MAP
fi





More information about the grass-dev mailing list