GRASS logo


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


raster, import, MODIS


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


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


Full path to single HDF file
Full path to file with list of HDF files
Name of spatial resampling method
Options: nearest, bilinear, cubic
Default: nearest
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
Full path to output file to use with t.register

Table of contents


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


The r.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.


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


General examples

Import of a single file with all the subsets (QA layers included) using GDAL:
r.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):

r.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:

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

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

r.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:

r.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:

r.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 settings=~/.rmodis product=ndvi_terra_sixteen_5600 \
  startday=2015-01-01 endday=2016-12-31 folder=$USER/data/ndvi_MOD13C1.006
# import band 1 = NDVI
r.modis.import files=$USER/data/ndvi_MOD13C1.006/listfileMOD13C1.006.txt spectral="( 1 )" \
  method=bilinear outfile=$USER/data/ndvi_MOD13C1.006/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
# r.modis.import using -w flag and outfile option)
t.register input=ndvi_16_5600m file=$USER/data/ndvi_MOD13C1.006/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 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:
r.modis.import -m files=$HOME/listfileMOD11A1.006.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

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())"
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.006, 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 r.modis.import with the w flag and outfile option.

# Import mosaics of LST Day for all dates using the list of downloaded files from 
# (see above) and get a list of the imported files along with
# dates to use with t.register in the temporal framework
r.modis.import -mw files=$HOME/listfileMOD11A1.006.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.006, December 2016"
t.register input=LST_Day_daily file=$HOME/list_for_tregister.csv


r.modis,, i.modis.qc

GRASS GIS Wiki: temporal data processing

Map of MODIS Land products' Sinusoidal grid tiling system


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

Last changed: $Date: 2017-05-05 23:09:59 +0200 (Fri, 05 May 2017) $


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

Main index | Raster index | Topics index | Keywords index | Graphical index | Full index

© 2003-2017 GRASS Development Team, GRASS GIS 7.2.3svn Reference Manual