[GRASS-user] bash script

Sandile Gumede akasandile at gmail.com
Thu Jun 24 05:08:55 EDT 2010


Thanks, The only problem I have now when I'm running the script, it gives me
an error saying LOCATION_NAME not set. See below:

#!/bin/sh

#variable to customize:
# path to GRASS software main directory
export GISBASE=/usr/lib/grass64
# path to GRASS database
GISDBASE=$HOME/grassdata

# nothing to change below
MAP=$1
LOCATION=$2


# generate temporal LOCATION:
TEMPDIR=tmp
mkdir -p $GISDBASE/$TEMPDIR/temp

# save existing $HOME/.grassrc6
if test -e $HOME/.grassrc6 ; then
mv $HOME/.grassrc6 /$GISDBASE/$TEMPDIR.grassrc6
fi

 echo "LOCATION_NAME: $TEMPDIR" > $HOME/.grassrc6
 echo "MAPSET:tmp" >> $HOME/.grassrc6
 echo "DIGITIZER: none" >> $HOME/.grassrc6
 echo "GISDBASE: $GISDBASE" >> $HOME/.grassrc6



# path to GRASS settings file:
export GISRC=$TEMPDIR/.grassrc6

# first our GRASS, then the rest
export PATH=$GISBASE/bin:$GISBASE/scripts:$PATH

# first have our private libraries:
export LD_LIBRARY_PATH=$GISBASE/lib:$LD_LIBRARY_PATH
export GRASS_LD_LIBRARY_PATH=$LD_LIBRARY_PATH

# settings for graphical output
PNGOUTPUTDIR=$TEMPDIR
# current date
DATE=`LC_ALL=C date -R | tr -s ' ' ' ' | cut -d' ' -f2,3,4 | tr -s ' ' '_'`
export GRASS_PNGFILE=$PNGOUTPUTDIR/grass6_recent_floods_${DATE}.png
export GRASS_TRUECOLOR=TRUE
export GRASS_WIDTH=900
export GRASS_PNG_COMPRESSION=1

# use process ID (PID) as lock file number:
export GIS_LOCK=$$

##### the algorithms goes here

error_routine () {
 echo "ERROR: $1"
 exit 1
}


# import DEM data set.
cd /home/tgumede1/grassdata
r.in.gdal input=TRMMLast1day.tif output=rainfall
# set region to default settings
g.region rast=rainfall

# import DEM data set.
r.in.gdal input=Dem_CF.tif output=dem
# set region to default settings
g.region rast=dem





On Thu, Jun 24, 2010 at 10:55 AM, Paul Kelly
<paul-grass at stjohnspoint.co.uk>wrote:

> Sandile Gumede wrote:
>
>> I'm using ubuntu, I installed grass from the synaptic. So the script to
>> start grass is in /usr/bin then the file name is grass64
>> (/usr/bin/grass64) and the scripts are in /usr/lib/grass64 then inside
>> grass64 folder you get other folder like scripts and so on. That is why
>> in my script I wrote:
>>
>
> Then your GISBASE should be /usr/lib/grass64
>
> The location of /usr/bin/grass64 is irrelevant - it is only a startup
> script to set appropriate environment variables, etc. You are doing all this
> in your script so you don't need to use the grass64 script at all (and GRASS
> doesn't need it for anything else).
>
> Hopefully that makes it clearer?
>
> Paul
>



-- 
Kind Regards
TS Gumede
CSIR, Meraka Institute
072 258 1650
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/grass-user/attachments/20100624/714ab5b8/attachment.html


More information about the grass-user mailing list