I would like to automate the import processes (if possible). I have several hundred tifs that I need to read into grass with r.in.gdal into an xy location (before I rectify them). The command:
r.in.gdal in=T56N.R9W.tif out=t56n.r9w.tif
works just fine.
Can anyone get me started setting up a script that could run through a directory full of tifs that looked something like this:
T56N.R10W.tif T61N.R19W.tif T64N.R4W.tif
T56N.R11W.tif T61N.R20W.tif T64N.R5W.1.tif
T56N.R12W.tif T61N.R2E.tif T64N.R5W.tif
T56N.R13W.1.tif add infinitum...
reading each tif into grass with r.in.gdal (the renameing bit is gravy... I can do that in a second step if necessary with a regular expression).
Thanks,
Kirk
------------------------------------------------------------------------
Kirk R. Wythers tel: 612.625.2261
Dept. of Forest Resources fax: 612.625.5212
University of Minnesota email: kwythers@umn.edu
------------------------------------------------------------------------
I would like to automate the import processes (if possible). I have
several hundred tifs that I need to read into grass with r.in.gdal into
an xy location (before I rectify them). The command:
r.in.gdal in=T56N.R9W.tif out=t56n.r9w.tif
works just fine.
Can anyone get me started setting up a script that could run through a
directory full of tifs that looked something like this:
T56N.R10W.tif T61N.R19W.tif T64N.R4W.tif
T56N.R11W.tif T61N.R20W.tif T64N.R5W.1.tif
T56N.R12W.tif T61N.R2E.tif T64N.R5W.tif
T56N.R13W.1.tif add infinitum...
reading each tif into grass with r.in.gdal (the renameing bit is
gravy... I can do that in a second step if necessary with a regular
expression).
within the directory full of tiffs:
for file in *.tif
do
newname = `echo $file | awk '{print tolower($1)}`
r.in.gdal in=$file out=$newname
done
Moritz
Moritz Lennert wrote:
newname = `echo $file | awk '{print tolower($1)}`
Apart from the syntax errors (there shouldn't be any spaces around the
equals sign, and the closing single quote is missing), I would expect
"tr" to be more efficient than awk:
newname=`echo $file | tr A-Z a-z`
Although, you could improve efficiency further (particularly on
Cygwin, where the overhead for spawning commands is substantial) with:
ls *.tif | awk '{print "r.in.gdal in=" $1 " out=" tolower($1)}' | sh
--
Glynn Clements <glynn.clements@virgin.net>
Moritz Lennert wrote:
newname = `echo $file | awk '{print tolower($1)}`
Apart from the syntax errors (there shouldn't be any spaces around the
equals sign, and the closing single quote is missing), I would expect
"tr" to be more efficient than awk:
newname=`echo $file | tr A-Z a-z`
Although, you could improve efficiency further (particularly on
Cygwin, where the overhead for spawning commands is substantial) with:
ls *.tif | awk '{print "r.in.gdal in=" $1 " out=" tolower($1)}' | sh
Don't know about the efficiency question, but I apologize to Kirk for the
careless syntax errors. Didn't take enough time for rereading what I
wrote.
Moritz