GRASS logo

Note: This addon document is for an older version of GRASS GIS that will be discontinued soon. You should upgrade your GRASS GIS installation, and read the current addon manual page.

NAME

i.modis.import - Import single or multiple tiles of MODIS products using pyModis.

KEYWORDS

raster, import, MODIS

SYNOPSIS

i.modis.import
i.modis.import --help
i.modis.import [-mtqwalg] [input=name] [files=name] [method=resampling] [mrtpath=name] [spectral=spectral subset] [outfile=name] [--overwrite] [--help] [--verbose] [--quiet] [--ui]

Flags:

-m
Create a mosaic for each date
-t
Preserve temporary files (TIF and HDF mosaic)
-q
Ignore the QA map layer
-w
Create a text file to use with t.register
-a
Append new file to existing file to use with t.register
-l
List more info about the supported MODIS products
-g
Print output message in shell script style
--overwrite
Allow output files to overwrite existing files
--help
Print usage summary
--verbose
Verbose module output
--quiet
Quiet module output
--ui
Force launching GUI dialog

Parameters:

input=name
Full path to single HDF file
files=name
Full path to file with list of HDF files
method=resampling
Name of spatial resampling method
Options: nearest, bilinear, cubic
Default: nearest
mrtpath=name
Full path to MRT directory
spectral=spectral subset
String of the form "( 1 0 1 0 )" to choose a subset of HDF layers to import
outfile=name
Full path to output file to use with t.register

Table of contents

DESCRIPTION

i.modis.import imports Level-3 MODIS (Moderate Resolution Imaging Spectroradiometer, flown on the two NASA spacecrafts Terra and Aqua) products into GRASS GIS.

NOTES

The i.modis modules need the pyModis library. Please install it beforehand.

The input file is given as a list of full paths to the MODIS HDF files, one per line. The input file(s) have to be inside the folder where the HDF files are stored.

If mrtpath is not used, pyModis will use GDAL to convert HDF files to TIF (which is faster).

The mrtpath option is the path to the main folder of the MODIS Reprojection Tools (MRT) binaries, i.e. the folder which contains the bin/ and the data/ folder, since these two folders are essential for obtaining a successful result.

Warning:

NOTE: In order to work with the temporal framework of GRASS GIS the flag w must be set during the import with i.modis.import.

Default subset of layers to import

User-defined subset of layers can be specified by spectral option. If not given, default values are applied.

MODIS AOD - Aerosol Optical Depth

SDS layerSpectralSpectral QA
Aerosol Optical Depth at 047 micron00
Aerosol Optical Depth at 055 micron11
AOD Uncertainty at 047 micron00
Fine-Mode Fraction for Ocean00
Column Water Vapor in cm liquid water00
AOD QA01
AOD Model (Regional background model used)00
Injection Height (Smoke injection height over local surface height) Grid 5km00
Cosine of Solar Zenith Angle00
Cosine of View Zenith Angle00
Relative Azimuth Angle00
Scattering Angle00
Glint Angle00

EXAMPLES

General examples

Import of a single file with all the subsets (QA layers included) using GDAL:
i.modis.import input=/path/to/file

Import of files from a list with all the subsets using MRT (if mrtpath is not provided, GDAL is used):

i.modis.import files=/path/to/listfile mrtpath=/path/to/mrt

Import of files from a list as mosaics per date without QA layers using MRT:

i.modis.import -mq files=/path/to/listfile mrtpath=/path/to/mrt

Import of a single file with user-specific subset of layers using GDAL:

i.modis.import input=/path/to/file spectral="( 1 0 1 0 )"

Import of files from a list with user-specific subset of layers and without QA layer using MRT:

i.modis.import -q files=/path/to/listfile mrtpath=/path/to/mrt spectral="( 1 )"

Import of a single subset of layers (i.e.: spectral="( 1 )") from each file of a list and write an outfile to be used with t.register to assign timestamps to maps in the temporal database and register them in a spacetime dataset. This option uses GDAL:

i.modis.import -wq files=/path/to/listfile spectral="( 1 )" outfile=/path/to/list_for_tregister.csv

Import of global MODIS NDVI data

The MOD13C1 is a global NDVI/EVI 16 days map product which can be downloaded and imported as follows in a latitude-longitude GRASS GIS location:
# download the two years worth of data
i.modis.download settings=~/.rmodis product=ndvi_terra_sixteen_5600 \
  startday=2015-01-01 endday=2016-12-31 folder=$USER/data/ndvi_MOD13C1.061
# import band 1 = NDVI
i.modis.import files=$USER/data/ndvi_MOD13C1.061/listfileMOD13C1.061.txt spectral="( 1 )" \
  method=bilinear outfile=$USER/data/ndvi_MOD13C1.061/list_for_tregister.csv -w
# create empty temporal DB
t.create type=strds temporaltype=absolute output=ndvi_16_5600m title="Global NDVI 16 days MOD13C1" \
  description="MOD13C1 Global NDVI 16 days" semantictype=mean
# register maps within spacetime datasets (the file name is provided by
# i.modis.import using -w flag and outfile option)
t.register input=ndvi_16_5600m file=$USER/data/ndvi_MOD13C1.061/list_for_tregister.csv

# verify and visualize timeline
t.rast.list ndvi_16_5600m
g.gui.timeline ndvi_16_5600m

Example of a complete workflow

Download the data: MOD11A1 from 2016-12-23 to 2016-12-31, tiles h18v04,h18v05
i.modis.download settings=$HOME/SETTING product=lst_terra_eight_1000 \
 tiles=h18v04,h18v05 startday=2016-12-23 endday=2016-12-31
Import mosaics of LST Day and QC Day bands for all dates in the list of files:
i.modis.import -m files=$HOME/listfileMOD11A1.061.txt \
 spectral="( 1 1 0 0 0 0 0 0 0 0 0 0 )"
Extract and apply the mandatory QA band (for more details see i.modis.qc):
for map in `g.list type=raster pattern="*_QC_Day"` ; do
 i.modis.qc input=${map} output=${map}_mandatory_qa \
  productname=mod11A1 qcname=mandatory_qa_11A1
done

for m in `g.list rast pat=*2016*LST_Day_1km` ; do
 # get name of product and date from filenames
 i=`echo $m | cut -c 1-16`
 # apply qa flags
 r.mapcalc --o expression="${m} = if(${i}_mosaic_QC_Day_mandatory_qa < 2, ${m}, null())"
done
Create the time series (i.e.: spacetime dataset) and register maps in it:
t.create type=strds temporaltype=absolute output=LST_Day_daily \
 title="Daily LST Day 1km" \
 description="Daily LST Day 1km MOD11A1.061, December 2016"
t.register -i input=LST_Day_daily \
 maps=`g.list type=raster pattern="*2016*LST_Day_1km" separator=comma` \
 start="2016-12-23" increment="1 day"
Verify list of maps and dates and visualize timeline:
t.rast.list LST_Day_daily
g.gui.timeline LST_Day_daily

It is also possible to create a time series using the list of maps with start and end time written by i.modis.import with the w flag and outfile option.

# Import mosaics of LST Day for all dates using the list of downloaded files from 
# i.modis.download (see above) and get a list of the imported files along with
# dates to use with t.register in the temporal framework
i.modis.import -mw files=$HOME/listfileMOD11A1.061.txt \
 spectral="( 1 0 0 0 0 0 0 0 0 0 0 0 )" outfile=$HOME/list_for_tregister.csv

# Create time series and register maps
t.create type=strds temporaltype=absolute output=LST_Day_daily \
 title="Daily LST Day 1km" \
 description="Daily LST Day 1km MOD11A1.061, December 2016"
t.register input=LST_Day_daily file=$HOME/list_for_tregister.csv

SEE ALSO

i.modis, i.modis.download, i.modis.qc

GRASS GIS Wiki: temporal data processing

Map of MODIS Land products' Sinusoidal grid tiling system

AUTHOR

Luca Delucchi, Google Summer of Code 2011; subsequently updated.

SOURCE CODE

Available at: i.modis.import source code (history)

Latest change: Mon Jun 28 07:54:09 2021 in commit: 1cfc0af029a35a5d6c7dae5ca7204d0eb85dbc55


Note: This addon document is for an older version of GRASS GIS that will be discontinued soon. You should upgrade your GRASS GIS installation, and read the current addon manual page.

Main index | Imagery index | Topics index | Keywords index | Graphical index | Full index

© 2003-2023 GRASS Development Team, GRASS GIS 7.8.8dev Reference Manual