[GRASSLIST:7539] Re: USGS DEMs in Grass

Gregory Booma gcb2101 at columbia.edu
Wed Jul 13 13:57:34 EDT 2005


Quoting Michael Kowen <newtograss at 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--




More information about the grass-user mailing list