[GRASSLIST:7532] USGS DEMs in Grass

Hello everyone,

I am trying to convert USGS DEMs into grass. Is there
a technique for this that can be easily integrated
into a script (I am trying to work with a fairly large
number of files)? The first method of conversion
that comes to mind is to import each DEM into a new
location and then integrate them into one map later.
Unfortunately I have been unable to write a script
that is capable of entering and exiting the grass
environment without rendering itself useless (after it
enters the environment the remainder of the commands
do not execute); is there some way around this, a
better scripting technique than using bash?

thanks very much,

Michael Kowen

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

Quoting Michael Kowen <newtograss@yahoo.com>:

I am trying to convert USGS DEMs into grass. Is there
a technique for this that can be easily integrated
into a script (I am trying to work with a fairly large
number of files)?

Here's an abbreviated version of a script I wrote for a similar
purpose (untested - use at your own risk). It assumes you have all
tiles in the same directory with no other files there. Simply set
your GRASS region to the full extent of your study area, and run
the script at the GRASS prompt. Unless I don't understand
completely what you're trying to do, there should be no need to
enter and exit GRASS repeatedly. Hope it's helpful:

#!/bin/bash
#convert.sh
#untested - use at your own risk!
#usage (at grass prompt): convert.sh /path/to/dir/containing/DEMs
output.file.name
#assumes region set to full extent of desired output mosaic

#--begin--

# change to the directory containing files
cd $1

# make list of tiles -> convert -> mosaic
list=""

for all in `ls *`
do
   file=`echo "$all"`
   if [ "$list" == "" ]; then
      list="$file"
    else
      list="$list,$file"
    fi

   #assumes USGS SDTS or ascii DEM
   r.in.gdal -oe in=$file out=$file
done

r.patch in=$list out=$2

#-- all done--