Well, after the trouble that I had yesterday I thought there was a need
for little bourne shell script here to make things a little easier.
So here is the the script of today from me. This script copies your favorite
color table from one cell file to another cell file that has the same
cell range of values. You have to know yourself that is makes sence to
copy the color table. Please write me comments if I have missed something.
Lars
Lars Schylberg Email: larss@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
#!/bin/sh
#
# cp.colr.sh
#
# Script to copy one color table from one raster map to another raster map
# Copies the colortable to: $LOCATION/colr2/mapset/cellname
# Read programmers manual 12.10.3.1 for details about colr2 files
#
# Author: Lars Schylberg ( larss@fmi.kth.se )
# Department of Geodesy and Photogrammetry
# Royal Inst. of Technolgy
# Stockholm, Sweden
#
# Date: 930323
# History of changes:
#
#--------------------------------------------------------------------------
# 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 ' input=mapname '
echo ' output=mapname '
echo
exit 1
fi
#
# parse input arguments
#
for i do
case $i in
input*)
INPUT=`echo $i | sed s/input=//` ;;
in*)
INPUT=`echo $i | sed s/in=//` ;;
i*)
INPUT=`echo $i | sed s/i=//` ;;
output*)
OUTPUT=`echo $i | sed s/output=//` ;;
out*)
OUTPUT=`echo $i | sed s/out=//` ;;
o*)
OUTPUT=`echo $i | sed s/o=//` ;;
*)
echo ""
echo "Unrecognized option: $i"
echo 'Options: input=mapname '
echo ' output=mapname '
echo
exit 1
esac
done
#-----------------------------------------------------------------------
# Check the input arguments
eval `g.findfile element=colr file=$INPUT`
if [ ! "$file" ] ; then
echo "$INPUT - color file not found"
exit 2
fi
INFILE=$file
INMAPSET=$mapset
eval `g.findfile element=cell file=$OUTPUT`
if [ ! "$file" ] ; then
echo "$OUTPUT - cell file not found"
exit 2
fi
#-----------------------------------------------------------------------------
# Make sure that output path exists
if [ ! "$LOCATION/colr2" ] ; then
mkdir $LOCATION/colr2
fi
if [ ! "$LOCATION/colr2/$INMAPSET" ] ; then
mkdir $LOCATION/colr2/$INMAPSET
fi
Copy the color file
cp $INFILE $LOCATION/colr2/$INMAPSET/$OUTPUT