Skip to content

Commit

Permalink
r.in.aster: add support for ASTER L1T data (OSGeo#3258)
Browse files Browse the repository at this point in the history
In addition, removed architecture dependent code for Mac.
  • Loading branch information
afrigeri authored Dec 1, 2023
1 parent fb69665 commit 4b6dcb9
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 11 deletions.
4 changes: 2 additions & 2 deletions scripts/r.in.aster/r.in.aster.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ <h2>DESCRIPTION</h2>

<em>r.in.aster</em> 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.
<p>The program may be run interactively or non-interactively from the command
line. In either case, the user must specify an <b>input</b> *.hdf file name,
the <b>type</b> of processing used, the image <b>band</b> to import, and an
<b>output</b> GRASS raster map name.
<p>The <b>type</b> parameter can take values of L1A, L1B, or DEM.
<p>The <b>type</b> parameter can take values of L1A, L1B, L1T or DEM.
<p>The <b>band</b> parameter can take values of 1, 2, 3n, 3b, 4-14

<h2>NOTES</h2>
Expand Down
36 changes: 27 additions & 9 deletions scripts/r.in.aster/r.in.aster.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -52,7 +52,6 @@
# %end

import os
import platform
import grass.script as grass

bands = {
Expand Down Expand Up @@ -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",
},
}


Expand Down Expand Up @@ -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]
Expand All @@ -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
Expand Down

0 comments on commit 4b6dcb9

Please sign in to comment.