Science‎ > ‎

MODIS code

Downloading MODIS data

There are several ways to acquire MODIS data. Depending on your needs you will have to resort to either the LP DAAC for tiled data or the ORNL DAAC for subsets of those tiles. The later is suitable for small scale studies or point measurements, the former is needed for global or continental scale studies that require full coverage of larger areas.


The Land Processes Distributed Active Archive Center (LP DAAC) provides several ways of accessing data. An overview of several ways of accessing the data is provided here:

However, non of them seemed really appealing and user friendly. Consequently I wrote a little bash scripted based upon ncftp. The script is called 'MODIS Batch Download Tool (MBDT)'. I coded a command line and gui version ( and respectively). Both can be found in the download section.

In case of the GUI version follow the onscreen instruction. The use of the command line tool is also straightforward.

foo@bar:~$ MCD12Q2 2001 all.tiles.txt

this will download all MCD12Q2 tiles for 2001 as listed in the all.tiles.txt file. The all.tiles.txt file is a list of all MODIS tiles of interest (in this case all available tiles). The format of the list is follows the standard MODIS tile nomenclature h##v## denoting the horizontal and vertical position of the MODIS tile.


As nicely described on the main site of the Oak Ridge National Laboratory (ORNL) DAAC: "The goal of the MODIS Land Product Subsets project is to provide summaries of selected MODIS Land Products for the community to use for validation of models and remote-sensing products and to characterize field sites. Output files contain pixel values of MODIS land products in text format and in GeoTIFF format. In addition, data visualizations (time series plots and grids showing single composite periods) are available."

Again several tools are available to access the DAAC. In addition to the existing python, matlab and standard perl web service clients I coded a more versatile perl client that will accommodate most of my and other user needs.

This perl script has four functions:

1. query the available products with 'list'
 foo@bar:~$ list

2. query the available bands of a product
foo@bar:~$ MCD12Q1

3. query the available dates of a product at a location
foo@bar:~$ MCD12Q1 40 -110

first parameter is the product name (see 1.)
second and third parameter are latitude and longitude

4. extract subsets of a product and band for a list of locations
and this for all available dates.
foo@bar:~$ MCD12Q1 Land_Cover_Type_1 1 1 input.csv

first parameter is the product name (see 1.)
second parameter is the band name (see 2.)
third parameter are the  # km east west of the location
fourth parameter are the # km north south of the location
fifth parameter is a csv file containing locations
The file format of the csv file is:
location name, latitude, longitude
(with no header and with UNIX UTF-8 line endings !!!)

Mosaicking MODIS data

As of yet there is no easily downloadable version of global or continental mosaicks of MODIS products including the MCD12Q2 phenology product. However, there is an easy fix to this problem and it involves 2 steps:

  1. download all wanted data (see above)
  2. create a mosaick of these data

A script and ancillary data to convert all hdf data to geotiff and make a mosaick in lat long ( is provided in the download section.

For this tool to work you need to extract the geotiff.headers.tar.gz files in your home directory. These include proper header info for every MODIS tile.

Given the non-standardized HDF format this sometimes runs askew using GDAL. HDF is a science data format with some GIS capabilities, however sometimes things don’t work properly. It depends on the product and some specific hdf tweaking…

foo@bar:~$ 2009 1 500 MCD43A4.mosaick.tif


  • 2009                -the year of interst
  • 1                     –the science data set (SDS) layer to use
  • 500                  –the resolution of the product (either 500m or 1000m for now)
  • MCD43… .tif     –the output file name

use the command below to see which layers you need. (1 to 4 = greenness increase, maximum, decrease and minimum for MCD12Q2 for example)

foo@bar:~$ gdalinfo some.MCD12Q2.tile.hdf


  • GDAL 1.7 and libgeotiff should be installed on your system
  • Keep in mind that generated files could be BIG