Unit 24 - MODIS

There are two satellites, Aqua and Terra which carry the MODIS sensor as payload. The Moderate Resolution Imaging Spectroradiometer (MODIS) is a 36-channel from visible to thermal-infrared sensor that was launched as part of the Terra satellite payload in December 1999 and Aqua satellite (May 2002). The Terra satellite passes twice a day (at about 10:30am, and 22:30pm local time), also the Aqua satellite passes twice a day (at about 01:30am, and 13:30pm local time). (source: GRASS Wiki)

Our area of interest, Germany, is covered by two tiles (see MODLAND grid):

  • h18v03
  • h18v04

Download and import

MODIS data is provided in 3 projections (Sinusoidal, Lambert Azimuthal Equal-Area, and Geographic). For our purpose, data will be reprojected to ETRS89 / LAEA Europe EPSG:3035.

Create a new GRASS location germany-modis (see Unit 02) using EPSG code (Select EPSG code of spatial reference system).


Fig. 116 Create a new location based on EPSG code.


Fig. 117 Enter EPSG code.

Enter a new GRASS session (PERMANENT mapset) and install i.modis addons extension (more about installing addons in Unit 17) for downloading and importing MODIS data (note that you have to install also pyMODIS Python Library).

pip3 install pymodis
g.extension extension=i.modis

GRASS MODIS addon consists of two modules:

Let’s download desired tiles (h18v03 and h18v04) for year 2019 by i.modis.download.


Already downloaded MODIS can be found in sample dataset in geodata/modis directory.

Land Surface Temperature eight day 1 Km (Terra/Aqua) product will be downloaded.

i.modis.download settings=settings.txt folder=/home/user/geodata/modis/h18v03_04 \
tiles=h18v03,h18v04 \
product=lst_aqua_eight_1000,lst_terra_eight_1000 \
startday=2019-01-01 endday=2019-12-31


Output folder (h18v03_04 in this case) must exists, otherwise the module will fail.

File settings.txt contains two lines: username and password for accessing MODIS download service.

Please read carefully how to register and set up your account on pyModis documentation.

Input MODIS data is imported by i.modis.import and reprojected into target location.

i.modis.import -mw files=/home/user/geodata/modis/h18v03_04/listfileMOD11A2.006.txt \
spectral='( 1 0 0 0 1 0 0 0 0 0 0 0 )' outfile=tlist-mod.txt

i.modis.import -mw files=/home/user/geodata/modis/h18v03_04/listfileMYD11A2.006.txt \
spectral='( 1 0 0 0 1 0 0 0 0 0 0 0 )' outfile=tlist-myd.txt

If -m flag is given mosaics from input tiles is created automatically, see Fig. 118.


Fig. 118 Mosaics created from h18v03 and h18v04 tiles.


In this section Land Surface Temperature (LST) analysis will be perfmored for Germany.

Let’s start by importing Germany administrative border located in the sample dataset osm/germany_boundary.gpkg.


Administrative border of Germany has been downloaded from OSM database.

/*added by auto repair*/
/*end of auto repair*/
ogr2ogr -f GPKG germany_boundary.gpkg -a_srs EPSG:4326 -t_srs EPSG:3035 /vsicurl_streaming/"\
%22%5D%3B%29%3B%28%2E%5F%3B%3E%3B%29%3Bout%3B%0A" lines

The input file contains national border represented by linestring, see Fig. 119 left part. It’s complication since a mask can be set only from area features (polygons). Input data have to be polygonized. This will be performed by two GRASS operations:

  • change line border to boundary by v.type (in GRASS topological model, an area is composition of boundaries and centroid, see Unit 03)
  • add centroid by v.centroids
v.type input=germany_boundary output=germany_b from_type=line to_type=boundary
v.centroids input=germany_b output=germany

Fig. 119 Germany national boundary as linestring on left and as polygon (area) on right part.

A mask can be created by r.mask. Don’t forget that a mask is created in the current computation region. Computation extent needs to be set based on Germany vector map and computational grid aligned by the input data by g.region.

g.region vector=germany align=MOD11A2.A2019001_mosaic_LST_Day_1km
r.mask vector=germany

Let’s check range values of our LST data (by r.info module or from Layer Manager).

r.info -r map=MOD11A2.A2019001_mosaic_LST_Day_1km

The values do not appear to be temperature. In order to determine LST from input data, digital values (DN) must be converted into Celsius or Kelvin scale.

\[C = DN * 0.02 - 273.15\]

Conversion to Celsium scale can be done by r.mapcalc (see Unit 05 - Simple computation for basic information about map algebra in GRASS). It’s also suitable to replace zero values with no-data value (NULL values in GRASS terminology).


r.mapcalc expression="MOD11A2.A2019001_mosaic_LST_Day_1km_c = \
if(MOD11A2.A2019001_mosaic_LST_Day_1km != 0, \
MOD11A2.A2019001_mosaic_LST_Day_1km * 0.02 - 273.15, null())"

Let’s check range values of new LST data layer.

r.info -r map=MOD11A2.A2017001_mosaic_LST_Day_1km_celsius

Fig. 120 LST reconstruction for Germany in Celsius scale (color table celsius applied).