#!/bin/sh # This program is Free Software under the GNU GPL (>=v2). # create a new LOCATION from a raster data set #variables to customize: GISBASE=/usr/local/grass53 GISDBASE=/usr/local/share/grassdata MAP=$1 LOCATION=$2 #nothing to change below: if [ $# -lt 2 ] ; then echo "Script to create a new LOCATION from a raster data set" echo "Usage:" echo " create_location.sh rasterfile location_name" exit 1 fi #generate temporal LOCATION: TEMPDIR=$$.tmp mkdir -p $GISDBASE/$TEMPDIR/temp #save existing $HOME/.grassrc5 if test -e $HOME/.grassrc5 ; then mv $HOME/.grassrc5 /tmp/$TEMPDIR.grassrc5 fi echo "LOCATION_NAME: $TEMPDIR" > $HOME/.grassrc5 echo "MAPSET: temp" >> $HOME/.grassrc5 echo "DIGITIZER: none" >> $HOME/.grassrc5 echo "GISDBASE: $GISDBASE" >> $HOME/.grassrc5 export GISBASE=$GISBASE export GISRC=$HOME/.grassrc5 export PATH=$PATH:$GISBASE/bin:$GISBASE/scripts # import raster map into new location: r.in.gdal -oe in=$MAP out=$MAP location=$LOCATION if [ $? -eq 1 ] ; then echo "An error occured. Stop." exit 1 fi #restore saved $HOME/.grassrc5 if test -f /tmp/$TEMPDIR.grassrc5 ; then mv /tmp/$TEMPDIR.grassrc5 $HOME/.grassrc5 fi echo "Now launch GRASS with:" echo " grass53 $GISDBASE/$LOCATION/PERMANENT"