From 4b6dcb9f2f430cd06ddc9a3d2279bd6ca34e95da Mon Sep 17 00:00:00 2001 From: Alessandro Frigeri Date: Fri, 1 Dec 2023 18:51:50 +0100 Subject: [PATCH] r.in.aster: add support for ASTER L1T data (#3258) In addition, removed architecture dependent code for Mac. --- scripts/r.in.aster/r.in.aster.html | 4 ++-- scripts/r.in.aster/r.in.aster.py | 36 ++++++++++++++++++++++-------- 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/scripts/r.in.aster/r.in.aster.html b/scripts/r.in.aster/r.in.aster.html index 2dc2ba17063..78aaf7a796a 100644 --- a/scripts/r.in.aster/r.in.aster.html +++ b/scripts/r.in.aster/r.in.aster.html @@ -2,12 +2,12 @@

DESCRIPTION

r.in.aster rectifies, georeferences, and imports Terra-ASTER imagery to current location using gdalwarp, hdf 4, and r.in.gdal, using projection parameters -from g.proj. It can import Level 1A, Level 1B, and relative DEM products. +from g.proj. It can import Level 1A, Level 1B, their relative DEM products, and Level 1T.

The program may be run interactively or non-interactively from the command line. In either case, the user must specify an input *.hdf file name, the type of processing used, the image band to import, and an output GRASS raster map name. -

The type parameter can take values of L1A, L1B, or DEM. +

The type parameter can take values of L1A, L1B, L1T or DEM.

The band parameter can take values of 1, 2, 3n, 3b, 4-14

NOTES

diff --git a/scripts/r.in.aster/r.in.aster.py b/scripts/r.in.aster/r.in.aster.py index 505a0d0cc04..07c993c0715 100755 --- a/scripts/r.in.aster/r.in.aster.py +++ b/scripts/r.in.aster/r.in.aster.py @@ -36,14 +36,14 @@ # % key: proctype # % type: string # % description: ASTER imagery processing type (Level 1A, Level 1B, or relative DEM) -# % options: L1A,L1B,DEM +# % options: L1A,L1B,L1T,DEM # % answer: L1B # % required: yes # %end # %option # % key: band # % type: string -# % description: List L1A or L1B band to translate (1,2,3n,...), or enter 'all' to translate all bands +# % description: List L1A L1B or L1T band to translate (1,2,3n,...), or enter 'all' to translate all bands # % answer: all # % required: yes # %end @@ -52,7 +52,6 @@ # %end import os -import platform import grass.script as grass bands = { @@ -90,6 +89,22 @@ "13": "TIR_Swath:ImageData13", "14": "TIR_Swath:ImageData14", }, + "L1T": { + "4": "SWIR_Swath:ImageData4", + "5": "SWIR_Swath:ImageData5", + "6": "SWIR_Swath:ImageData6", + "7": "SWIR_Swath:ImageData7", + "8": "SWIR_Swath:ImageData8", + "9": "SWIR_Swath:ImageData9", + "1": "VNIR_Swath:ImageData1", + "2": "VNIR_Swath:ImageData2", + "3n": "VNIR_Swath:ImageData3N", + "10": "TIR_Swath:ImageData10", + "11": "TIR_Swath:ImageData11", + "12": "TIR_Swath:ImageData12", + "13": "TIR_Swath:ImageData13", + "14": "TIR_Swath:ImageData14", + }, } @@ -133,13 +148,17 @@ def main(): "13", "14", ] + + # Band 3b is not included ASTER L1T + if proctype == "L1T": + allbands.remove("3b") if band == "all": bandlist = allbands else: bandlist = band.split(",") - # initialize datasets for L1A and L1B - if proctype in ["L1A", "L1B"]: + # initialize datasets for L1A, L1B, L1T + if proctype in ["L1A", "L1B", "L1T"]: for band in bandlist: if band in allbands: dataset = bands[proctype][band] @@ -165,10 +184,9 @@ def import_aster(proj, srcfile, tempfile, output, band): grass.message(_("Georeferencing aster image ...")) grass.debug("gdalwarp -t_srs %s %s %s" % (proj, srcfile, tempfile)) - if platform.system() == "Darwin": - cmd = ["arch", "-i386", "gdalwarp", "-t_srs", proj, srcfile, tempfile] - else: - cmd = ["gdalwarp", "-t_srs", proj, srcfile, tempfile] + # We assume gdal is build natively for the platform GRASS is running on. + # see #3258 + cmd = ["gdalwarp", "-t_srs", proj, srcfile, tempfile] p = grass.call(cmd) if p != 0: # check to see if gdalwarp executed properly