d.rast.zoom2 script
Rick Thompson
rick at cast.uark.edu
Thu Apr 21 12:24:45 EDT 1994
GRASS users,
This script may be useful to you for specialized zooming in and out of data;
I found it useful for visually checking imagery in GRASS.
----------------------------- Cut Here ---------------------------------------
:
# *** d.rast.zoom2 ***
# Written by Rick Thompson
#
# @(#) d.rast.zoom2: allows repetitive display and interactive d.zooming of up
# @(#) to 1 raster map, 1 raster overlay map, and 2 vector files,
# @(#) plus d.zooming back out in the reverse order. Additionally,
# @(#) a region can be saved, the original raster file's region
# @(#) can be returned to, or the user can do a one-time display
# @(#) of a new raster or vector file.
# @(#) Last revision: 4/20/94
ARCH=`uname -m`
if [ $ARCH = mips ] ; then
ECHON="/usr/bsd43/bin/echo -n"
else
ECHON="echo -n"
fi
if [ "$GISRC" = "" ] ; then
clear
echo "This command must be run from GRASS!"
echo ''
exit 1
fi
name=''
clear
echo ''
resp="n"
until [ "$resp" = "y" ] ; do
g.ask type=mapset prompt="Please select a raster map:" element=cell desc=raster unixfile=/tmp/$$
. /tmp/$$
rm -f /tmp/$$
if [ ! -f $LOCATION/cell/$name ]; then
echo "Raster map $name not found in mapset $MAPSET."
resp="n"
echo ''
else
rast="$name"
name=''
resp="y"
fi
done
echo ''
resp="n"
until [ "$resp" = "y" ] ; do
$ECHON "Do you want to specify a raster overlay map, too? (y/n) "
read ans
if [ "$ans" = "y" -o "$ans" = "Y" ] ; then
echo ''
g.ask type=mapset prompt="Please select an overlay raster map:" element=cell desc=raster unixfile=/tmp/$$
. /tmp/$$
rm -f /tmp/$$
if [ ! -f $LOCATION/cell/$name ]; then
echo "Overlay raster map $name not found in mapset $MAPSET."
resp="n"
echo ''
else
overlay="$name"
name=''
resp="y"
fi
else
break
fi
done
echo ''
$ECHON "Would you like to display a vector map? (y/n) "
read ans
if [ "$ans" = "y" -o "$ans" = "Y" ] ; then
echo ''
g.ask type=mapset prompt="Which vector map?" element=dig desc=vector unixfile=/tmp/$$
. /tmp/$$
rm -f /tmp/$$
if [ ! -f $LOCATION/dig/$name ]; then
echo "Vector map $name not found in mapset $MAPSET."
resp="n"
echo ''
else
vect="$name"
name=''
resp="y"
$ECHON "What color should be assigned to $vect? "
read col
fi
else
break
fi
if [ -n "$vect" ] ; then
echo ''
$ECHON "Would you like to display a 2nd vector map (y/n)? "
read ans
if [ "$ans" = "y" -o "$ans" = "Y" ] ; then
echo ''
g.ask type=mapset prompt="Which vector map?" element=dig desc=vector unixfile=/tmp/$$
. /tmp/$$
rm -f /tmp/$$
if [ ! -f $LOCATION/dig/$name ]; then
echo "Vector map $name not found in mapset $MAPSET."
resp="n"
echo ''
else
vect2="$name"
name=''
resp="y"
$ECHON "What color should be assigned to $vect? "
read col2
fi
else
break
fi
fi
g.region rast="$rast"
res=`g.region -g | grep nsres | cut -d"=" -f2 | tr -d ' '`
d.erase
d.rast "$rast"
if [ -f $LOCATION/cell/"$overlay" ] ; then
d.rast -o "$overlay"
fi
if [ -n "$vect" ] ; then
d.vect "$vect" c=$col
fi
if [ -n "$vect2" ] ; then
d.vect "$vect2" c=$col2
fi
g.region save=rastzoomtmp1
response="y"
i=1
until [ "$response" = "n" -o "$response" = "N" ] ; do
clear
echo ''
echo "Please select one of these actions to:"
echo ''
echo "1 - use the interactive d.zoom"
echo "2 - go to the previous zoom"
echo "3 - go to a designated region"
echo "4 - return to $rast""'s"" region"
echo "5 - save the current region"
echo "6 - do a one time display of a new raster map"
echo "7 - do a one time display of a new vector map"
echo "8 - quit"
echo ''
$ECHON "Please enter the appropriate number: "
read number
case $number in
1) i=`expr $i + 1`
d.zoom -q
g.region save=rastzoomtmp$i
d.erase
d.rast "$rast"
if [ -f $LOCATION/cell/"$overlay" ] ; then
d.rast -o "$overlay"
fi
if [ -n "$vect" ] ; then
d.vect "$vect" c=$col
fi
if [ -n "$vect2" ] ; then
d.vect "$vect2" c=$col2
fi;;
2) i=`expr $i - 1`
if [ $i = 0 ] ; then
echo "No previous zooming windows remain. Would you like to view"
$ECHON "the default region? (y/n) "
read ans
if [ "$ans" = "y" -o "$ans" = "Y" ] ; then
g.region -d res=$res
d.erase
d.rast "$rast"
if [ -f $LOCATION/cell/"$overlay" ] ; then
d.rast -o "$overlay"
fi
fi
if [ -n "$vect" ] ; then
d.vect "$vect" c=$col
fi
if [ -f "$vect2" ] ; then
d.vect "$vect2" c=$col2
fi
elif [ $i -lt 0 ] ; then
echo ''
echo "No previous zooming windows remain."
echo ''
sleep 3
else
g.region region=rastzoomtmp$i
d.erase
d.rast "$rast"
if [ -f $LOCATION/cell/"$overlay" ] ; then
d.rast -o "$overlay"
fi
if [ -n "$vect" ] ; then
d.vect "$vect" c=$col
fi
if [ -n "$vect2" ] ; then
d.vect "$vect2" c=$col2
fi
fi;;
3) echo ''
echo 'The region is based on:'
echo ''
echo '1 - raster file'
echo '2 - vector file'
echo '3 - region file'
echo ''
$ECHON 'Please enter the appropriate number: '
read regno
case $regno in
1) echo ''
type="rast";;
2) echo ''
type="vect";;
3) echo ''
type="region";;
esac
g.list "$type"
echo ''
$ECHON "Enter the $type region you want: "
read newreg
g.region "$type"="$newreg"
d.erase
d.rast "$rast"
if [ -f $LOCATION/cell/"$overlay" ] ; then
d.rast -o "$overlay"
fi
if [ -n "$vect" ] ; then
d.vect "$vect" c=$col
fi
if [ -n "$vect2" ] ; then
d.vect "$vect2" c=$col2
fi;;
4) g.region rast="$rast"
d.erase
d.rast "$rast"
if [ -f $LOCATION/cell/"$overlay" ] ; then
d.rast -o "$overlay"
fi
if [ -n "$vect" ] ; then
d.vect "$vect" c=$col
fi
if [ -n "$vect2" ] ; then
d.vect "$vect2" c=$col2
fi;;
5) echo ''
$ECHON "Enter the name by which to save this region: "
read nreg
g.region save=$nreg;;
6) echo ''
g.ask type=mapset prompt="Please select the tmp raster map:" element=cell desc=raster unixfile=/tmp/$$
. /tmp/$$
rm -f /tmp/$$
if [ ! -f $LOCATION/cell/$name ]; then
echo "Raster map $name not found in mapset $MAPSET."
resp="n"
echo ''
else
rname="$name"
name=''
d.rast -o "$rname"
fi;;
7) echo ''
g.ask type=mapset prompt="Please select the tmp vector map:" element=dig desc=vector unixfile=/tmp/$$
. /tmp/$$
rm -f /tmp/$$
if [ ! -f $LOCATION/dig/$name ]; then
echo "Vector map $name not found in mapset $MAPSET."
echo ''
else
vname="$name"
name=''
echo ''
echo -n "Enter $vname""'s"" color: "
read vnamcol
d.vect "$vname" c=$vnamcol
fi;;
8) rm $LOCATION/windows/rastzoomtmp*
exit 0;;
esac
done
rm $LOCATION/windows/rastzoomtmp*
------------------------------------------------------------------------
Rick Thompson- Research Assistant E-mail: rick at cast.uark.edu
Center for Advanced Spatial Technologies Telephone: (501) 575-5736
Ozark Hall Rm. 12 Fax: 575-3846
University of Arkansas
Fayetteville, AR 72701
More information about the grass-user
mailing list