----------
X-Sun-Data-Type: text
X-Sun-Data-Description: text
X-Sun-Data-Name: text
X-Sun-Content-Lines: 8
Check out the attached script.
Bill Jackson
ENL
USA-CERL
----------
X-Sun-Data-Type: default
X-Sun-Data-Description: default
X-Sun-Data-Name: site.to.rast
X-Sun-Content-Lines: 80
##############################################################################
Here is a solution for a non-interactive conversion of sites data to raster
that was recommended by Michael Shapiro [I believe Michael has also placed
source code on moon which provides non-interactive versions of the individual
s.menu options]:
:
# received from shapiro 911202 as sites_to_cell solution
# then modified
USAGE="$0 [-q quadsize] [-t title] sites_list [raster]"
if [ $# -eq 0 -o ${1-""} = "help" ]
then
echo $USAGE
echo " sites_list = name of the input sites list"
echo " raster = name of the output raster file (default: same as sites)"
echo ' quadsize = size of each site in cells'
echo ' (default: "0" == 1 cell, see s.menu)'
echo ' title = title for raster map'
echo ' (default: "created from sites file $sites")'
exit -1
fi
# continue only if user is executing GRASS
if [ "$GISRC" = "" ]
then
echo "Sorry, you are not running GRASS" >&2
exit 4
else
USERGRASS="$GISDBASE/$LOCATION_NAME/$MAPSET"
fi
# set defaults, then test for user-specified settings
while [ `echo $1 | cut -c1` = "-" ]
do
case $1 in
-q) quadsize=$2
;;
-t) title=$2
;;
*) echo "$1 is not a valid flag"
exit -1
;;
esac
shift 2
done
sites=$1
raster=$2
# remove the raster map to be safe
g.remove ${raster:=$sites} >/dev/null
# output sites file to a file in /tmp
tmp=/tmp/$$
rm -f $tmp
s.out.ascii -ad $sites fs='|' > $tmp
# run the program which converts sites to cell
# the command line has unix-path name of sites file
# the input is
# quadsize
# name of output raster map
# title for raster map
echo "converting sites list $sites to raster $raster"
$GISBASE/etc/sites/sites_to_cell $tmp << EOF
${quadsize:=0}
$raster
${title:="created from sites file $sites"}
EOF
status=$?
rm -f $tmp
exit $status