Building MOD14_SPA

23.05.2011 13:33 ·  GIS  ·  howto

MODIS Active Fire Product (MOD14) Science Processing Algorithm MOD14_SPA is an open-source implementation of the MODIS space imagery fire detection algorithm. You can find binary builds of the tool on NASA’s Direct Readout Laboratory (DRL) site, but only for some (rather old and 32-bit) Linux distributions. Fortunately, you can also download the source archive and build the tool yourself. In this post, I will show you how to do that.

General information

The MODIS Active Fire Product (MOD14) science processing algorithm MOD14_SPA uses the pixel brightness values of channels 4 and 11 in the micrometre range (MODIS channels 21, 22, and 31) to detect fires. Channels 1, 2, 7, and 32 are used for cloud masking and false alarm reduction. The input data is a MODIS Level 1B file. The output is a two-dimensional fire mask in HDF (Hierarchical Data Format).

The source code of the application is available for free on the Direct Readout Laboratory download page. You have to register to get the code. At the time of writing, the latest version of this algorithm is 5.0.1.

Building on Windows

In addition to the application source code, we need the following libraries:

All these libraries, except the optional SZIP, can be installed using the OSGeo4W installer. In this post, I will assume that the libraries have been downloaded and installed into the default directory (C:\OSGeo4W).

We also need the GCC compiler, or rather, its Windows variant — MinGW. There are several ways to install it:

I recommend installing it in a directory that does not contain spaces and/or non-ASCII characters in the name. After installation, it is necessary to check that the PATH variable contains the path to the bin directory of the installed MinGW.

Unpack the downloaded archive. The source code of the applications can be found in the algorithm directory. As the applications were originally developed for OC Linux, it is necessary to edit the misc.c file before building them to look like this:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

char *make_uname(void)
{
  static char unamestr[] = "MS Doors";

  return unamestr;
}

You can replace MS Doors with any identifier.

Now edit the Makefile. In line 9, specify the path to the directory where the HDF4 library files are located. Since we installed it using the OSGeo4W installer, this line will look like this

HDFHOME = C:/OSGeo4W

Line 50 should be changed to

LIB = -L$(HDFLIB) -lmfhdf -lhdf -ljpeg_i -lzlib -lm

When the changes are saved, open a console window, change to the directory containing the MOD14_SPA source code, and execute the following command

mingw32-make

After a short build process, there should be two executables in the directory: mod14.exe and fireloc.exe.

Building on Linux

Linux users are luckier. First of all, they don’t need to compile because the source archive contains a statically compiled executables for Intel-compatible 32-bit systems (compiled on Fedora Core 4 using the gcc 4.0.2 compiler). Second, self-compiling is much easier compared to Windows. We need the same libraries as for Windows, namely:

The ZLIB and JPEG libraries are most likely already installed; you just need to make sure that the “dev” versions of the corresponding packages are present in addition to the libraries themselves. This can be done using your distribution’s package manager. The HDF4.2.x library can be obtained in several ways:

I also assume that all necessary libraries are installed. After unpacking the source archive, change to the algorithm directory. Before building, it is necessary to edit the Makefile, specifying the used compiler (GCC is used by default), besides, you can change the compiler options if necessary. Also, in the HDFHOME variable, specify the path to the directory where the HDF library is installed (usually it is /usr or /usr/local). Then run the following command

make clean

to clean the directory of existing binaries, and then

make

to start compilation.

⮜ Prev
Next ⮞