[GRASS-dev] changes in r.in.aster

Hi all

After an unsuccessful import of ASTER images, I went looking into the r.in.aster script and made a few changes that allowed me to import correctly the images.

OS: Mac OSX El Capitan (with Michael’s binary version 7.0.3)

The original issues: The individual bandas were being imported with 15m resolution for all bands (the region wasn’t being re-set for the coarser resolutions), and all bands imported after 3B had the southern section of the 3B band (the temp file wasn’t being reseted).

My changes:

1 - I changed the band names from 1,2,3b… to 01, 02, 03b… so they are listed in the right order by the gui (instead of 1, 10, 11,…)

2 - I moved the lines:

tempfile = grass.read_command(“g.tempfile”, pid = os.getpid()).strip() + ‘.tif’

grass.try_remove(tempfile)

to the loop:

if proctype in [“L1A”, “L1B”]:
for band in bandlist:
if band in allbands:

so the tempfile is created and destroyed for each band, assuring it is created according to the band spatial extent and resolution.

3 - This line was giving me errors:

if platform.system() == “Darwin”:
cmd = [“arch”, “-i386”, “gdalwarp”, “-t_srs”, proj, srcfile, tempfile ]

arch: posix_spawnp: gdalwarp: Bad CPU type in executable

This is probably because I run OSC El Cap, which is 64bits. So to get it working, I had to ignore this system test and use

cmd = [“gdalwarp”, “-t_srs”, proj, srcfile, tempfile ]

Nut I’m not sure what would be the best way to keep the test and maintain compatibility with older systems. Perhaps a try/except would do.

I attached the modified version.

best

Carlos

(attachments)

r.in.aster2 (5.39 KB)

···

Prof. Carlos Henrique Grohmann
Institute of Energy and Environment - Univ. of São Paulo, Brazil

  • Digital Terrain Analysis | GIS | Remote Sensing -

http://carlosgrohmann.com
http://orcid.org/0000-0001-5073-5572


Can’t stop the signal.

On Wed, Mar 16, 2016 at 12:30 PM, Carlos Grohmann <carlos.grohmann@gmail.com

wrote:

3 - This line was giving me errors:
    if platform.system() == "Darwin":
        cmd = ["arch", "-i386", "gdalwarp", "-t_srs", proj, srcfile,
tempfile ]

arch: posix_spawnp: gdalwarp: Bad CPU type in executable

This is probably because I run OSC El Cap, which is 64bits. So to get it
working, I had to ignore this system test and use

cmd = ["gdalwarp", "-t_srs", proj, srcfile, tempfile ]

Nut I'm not sure what would be the best way to keep the test and maintain
compatibility with older systems. Perhaps a try/except would do.

Try/except sounds like a good solution which is also Pythonic. I think you
should keep if statement there (inside the except).

Here is the history of the file [1, 2]. Perhaps Michael can comment on
whether this check makes even sense now. It is a distribution issue, so if
we can avoid solving it in the source code, it will be good.

Vaclav

[1]
https://trac.osgeo.org/grass/browser/grass/trunk/scripts/r.in.aster/r.in.aster.py?annotate=blame
[2] https://trac.osgeo.org/grass/changeset/32178