[GRASS-user] shell scripting problem

Kirk Wythers kirk.wythers at gmail.com
Thu Sep 13 06:43:53 PDT 2012


I am perplexed by some odd scripting behavior and am hoping that someone can point out the (probably stupid) mistake I am making. 

I use a simple for loop with g.mlist an r.what to query some climate data. I have run this script before and never had any trouble with it. However, today I notice that it is returning fewer data points from my climate data than the number of coordinates that I am querying. For example I have a file "coords" that contains 8973 lines of coordinates. This should return 8973 lines of data from grass. However, the script is returning 8925 lines of data. I'm not getting any errors and can think of no reason the script should behave this way.

Any ideas?



Here is a copy of my shell script

#!/bin/bash

#test to see if script is being run from GRASS

if test "$GISBASE" = ""; then
       echo "You must be in GRASS to run this program"
       exit
fi

# Use input text file for coords in the format: lon lat (easting northing) single 
# space between coords. Example: -98.42072 55.91481. Must use real coordinates, no blanks. 
# Script will create file for each $MAP in the list. g.mlist can also take the "pattern"
# argument which takes regular expressions. For example: pattern="*" returns all 
# maps in the database.

for MAP in `g.mlist type=rast pattern="HIST_bio_12"`; do
   r.what --verbose input="$MAP" < ~/Desktop/worldclim/coords > ~/Desktop/worldclim/"$MAP".txt;

echo "$MAP"

done


More information about the grass-user mailing list