A script to copy raster files between locations

Lars Schylberg larss at fmi.kth.se
Tue Jan 19 03:26:58 EST 1993


Here is a small script that I wrote this morning.
I thought this script could be useful for other people then me.
It copies one raster cell file from current location to another
existing location.

Lars

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

------------------ cut here -------------------------------------
#!/bin/sh
#
#  g.cp.rast.sh
#
#  Author: Lars Schylberg
#  email: larss at fmi.kth.se
#  
#  Date: 930119
#
#------------------------------------------------------------------------
# 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 '       rast=mapname '
    echo '       location=target location path '
    echo
    echo '  This program copies a raster cell file from '
    echo '  current location to a specified existing location. '
    echo '  The new location have to be specified with a full path. '
    echo
    exit 1
fi

#				 Parse input arguments

for i do
	case $i in
		rast=*)
			RAST=`echo $i | sed s/rast=//` ;;
		ra=*)
			RAST=`echo $i | sed s/ra=//` ;;
		r=*)
			RAST=`echo $i | sed s/r=//` ;;
		location=*)
			NLPATH=`echo $i | sed s/location=//` ;;
		loc=*)
			NLPATH=`echo $i | sed s/loc=//` ;;
		l=*)
			NLPATH=`echo $i | sed s/l=//` ;;
		*)
			echo ""
			echo "Unrecognized option: $i"
			echo 'Options: rast=mapname '
                        echo '         location=target location path '
			exit 1
	esac
done
#-------------------------------------------------------------------------

#				 Check the input arguments

eval `g.findfile element=cell file=$RAST`
if [ ! "$file" ]
then
    echo "$RAST - cell file not found"
    exit 2
fi

if test -f $NLPATH/WIND
then
  cp $LOCATION/cell/$RAST $NLPATH/cell/
  cp $LOCATION/cellhd/$RAST $NLPATH/cellhd/
  cp $LOCATION/cats/$RAST $NLPATH/cats/
  cp $LOCATION/colr/$RAST $NLPATH/colr/
  cp $LOCATION/hist/$RAST $NLPATH/hist/
  cp $LOCATION/cell_misc/$RAST/* $NLPATH/cell_misc/$RAST/
else
  echo "No such location path: $NLPATH "
  exit 2
fi




More information about the grass-dev mailing list