#!/bin/sh # This program is Free Software under the GNU GPL (>=v2). # create a new LOCATION from a raster data set # Cited from the book: # Markus Neteler and Helena Mitasova: # Open Source GIS: A GRASS GIS Approach. # Kluwer Academic Publishers, Boston, Dordrecht, 464 pp, # ISBN: 1-4020-7088-8, http://mpa.itc.it/grasstutor/ #variables to customize: GISBASE=/usr/local/grass5 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 " grass5 $GISDBASE/$LOCATION/PERMANENT"