Ubuntu – Compiling MODIS Data with .hdf Extension Using GDAL

gdalhdfmodisUbuntu

I am trying to use GDAL to read .hdf file, but it does not seem to recognize the extension. It works fine in Windows system.

The GDAL open command gives the following error message:

ERROR 4: `MYD06_L2.A2014002.0645.006.2014269075802.hdf' not recognised
as a supported file format.

You can access the .hdf file from this link [~80 MB].

Best Answer

Thank you everyone for your help. I have finally solved this issue, and I would like to explain the procedure to do the same.

  1. Clear previous installations of gdal in your Ubuntu system.

    $sudo apt-get remove gdal-bin
    $sudo pip uninstall gdal
    $sudo apt-get remove python-gdal
    
  2. Download GDAL source from this link . You can browse and download one of the stable releases.

  3. Now, do the system install by these steps.

    $ cd gdal
    $ ./configure --disable-netcdf --disable-fortran --with-python
    $ make
    $ su
    Password: ********
    $ make install
    $ exit
    

This installs GDAL with python bindings in your ubuntu worstation. It will have HDF4 file support for processing MODIS data.

Please note that you need to use Python 2.7.6 (I have tested using this python) to process HDF4 files. You cannot use iPython to process HDF4 files.

P.S. : Thanks to my dear friend Florian M. Savoy who assisted me in solving this problem.

Related Question