[GRASS-user] automated import via r.in.gdal

Hello,
I have a bunch of landsat images which I would like to import all into one location. The files are all in the same directory.

How do I write a script to import them all at once:

like

start Grass with MyLocation

for file in path/to/files/
r.in.gdal -e in=path/to/files/
FILENAME.tif out=FILENAME

exit grass

I know bash a little bit and some small python.

Thanks for your hints,
Timmie

Tim Michelsen <timmichelsen <at> gmx-topmail.de> writes:

Hello,
I have a bunch of landsat images which I would like to import all into
one location. The files are all in the same directory.

How do I write a script to import them all at once:

like

start Grass with MyLocation

for file in path/to/files/
r.in.gdal -e in=path/to/files/
FILENAME.tif out=FILENAME

try:

for f in /path/*.tif
do
   export fnam=`basename $f .tif`
   r.in.gdal -e $f out=${fnam}
done

Timmie wrote:

Hello,
I have a bunch of landsat images which I would like to import all into
one location. The files are all in the same directory.
...

I have uploaded my scripts to bulk process LANDSAT-TM5/7
scenes from GLCF Maryland to

http://www.grassbook.org/examples_menu3rd.php
    * glcf_landsat7_for_NC_SPM_WAKE_process.sh (reproject, spatial subset
with GDAL)
    * glcf_landsat5_for_NC_SPM_WAKE_import.sh (import into GRASS)
    * glcf_landsat7_2000_for_NC_SPM_WAKE_import.sh (import into GRASS)
    * glcf_landsat7_2002_for_NC_SPM_WAKE_import.sh (import into GRASS)

Maybe useful for you... You can then run something like:

i.landsat.rgb b=lsat5_1987.10 g=lsat5_1987.20 r=lsat5_1987.30
i.landsat.rgb b=lsat7_2000.10 g=lsat7_2000.20 r=lsat7_2000.30
i.landsat.rgb b=lsat7_2002.10 g=lsat7_2002.20 r=lsat7_2002.30

d.rgb b=lsat5_1987.10 g=lsat5_1987.20 r=lsat5_1987.30
d.rgb b=lsat7_2000.10 g=lsat7_2000.20 r=lsat7_2000.30
d.rgb b=lsat7_2002.10 g=lsat7_2002.20 r=lsat7_2002.30

to see them in rather natural colors.

Markus
--
View this message in context: http://www.nabble.com/automated-import-via-r.in.gdal-tf4378395.html#a12485887
Sent from the Grass - Users mailing list archive at Nabble.com.

Tim Michelsen wrote:

I have a bunch of landsat images which I would like to import all into
one location. The files are all in the same directory.

How do I write a script to import them all at once:

like

start Grass with MyLocation

for file in path/to/files/
r.in.gdal -e in=path/to/files/
FILENAME.tif out=FILENAME

exit grass

have a look at the $GRASS_BATCH_JOB enviro variable in GRASS 6.3 if you
want to script have grass start up, do something, then exit.
(still missing from the grass6 man page AFAICT)

Hamish