[GRASS-user] landsat import with python-script

Dear grass-list,

I tried to perform an automated import of landsat imagery using the python
script (found here:
http://grass.osgeo.org/wiki/LANDSAT#Automated_data_import).

After starting the python-script, I get the following error-message:

The structure of the folder 'LS5_125_049_20050504' is as follows:

Anybody has an idea, why the py-script cannot define the 'band' name?

Stefan

--
View this message in context: http://osgeo-org.1560.n6.nabble.com/landsat-import-with-python-script-tp4366043p4366043.html
Sent from the Grass - Users mailing list archive at Nabble.com.

Stefan wrote:

I tried to perform an automated import of landsat imagery
using the python
script (found here:
http://grass.osgeo.org/wiki/LANDSAT#Automated_data_import).

After starting the python-script, I get the following
error-message:

The structure of the folder 'LS5_125_049_20050504' is as
follows:

Anybody has an idea, why the py-script cannot define the
'band' name?

Stefan

--
View this message in context: http://osgeo-org.1560.n6.nabble.com/landsat-import-with-python-script-tp4366043p4366043.html
Sent from the Grass - Users mailing list archive at
Nabble.com.

weird, nabble seems to have removed the attachments.

anyway, here they are from the nabble site:

:~ ./import_landsat.py LS5_125_049_20050504/
Importing L5125049_04920050504_B70.TIF -> B70@LS5_125_049_20050504/...
Traceback (most recent call last):
  File "./import_landsat.py", line 87, in <module>
    main()
  File "./import_landsat.py", line 84, in main
    import_tifs(sys.argv[1])
  File "./import_landsat.py", line 47, in import_tifs
    title = 'band %d' % band)
NameError: global name 'band' is not defined

the "band" variable was never set in the script. it's a bug
on the wiki page.

I guess you need to change:
        kanal = int(name[-2])
to:
        band = int(name[-2])

in the code.

Hamish

Thanks Hamish, that works fine!

--
View this message in context: http://osgeo-org.1560.n6.nabble.com/landsat-import-with-python-script-tp4366043p4371247.html
Sent from the Grass - Users mailing list archive at Nabble.com.

Hi Stefan
Thanks for your response. I am trying to achieve this on a windows 7 64 bit
platform, with GRASS GIS 6.4.2RC2. The syntax must then be different...The
"grass shell" is that the grass gis command line window?

What prerequisites are needed for the location of the scripts and the data?
Need to be in the same folder?

Rasmus

----------------
Hi Rasmus,

could you please post that on the forum? I think it is better to discuss
these issues in the forum so others can participate and also learn from it.

I have no experiences using python scripts on the grass gui, so far I only
used it from the grass shell, e.g. like this:

./import_landsat.py 129_048_20060228_LS5

assuming you are working on Linux and '129_048_20060228_LS5' is the folder
where the landsat TIF-files and metadata is stored. Like this you could
easily create a loop and process all your folders at once.

Stefan

--
View this message in context: http://osgeo-org.1560.n6.nabble.com/landsat-import-with-python-script-tp4366043p4983130.html
Sent from the Grass - Users mailing list archive at Nabble.com.

Hi Rasmus,

right, the "grass shell" is the command line window. 'Shell' because it's
the linux shell console (but grass command line also works on other
terminals).

I guess the syntax for starting a python-script in windows will be slightly
different.

Yes, the script should be in the working folder if you do not specify the
location further.

Stefan

--
View this message in context: http://osgeo-org.1560.n6.nabble.com/landsat-import-with-python-script-tp4366043p4983229.html
Sent from the Grass - Users mailing list archive at Nabble.com.