4

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].

  • Do you have QGIS in Ubuntu? The *.hdf support it would be installed. – xunilk Apr 8 '16 at 12:02
  • In a bash what is the result of gdalinfo MYD06_L2.A2014002.0645.006.2014269075802.hdf and gdalinfo --formats? – Kersten Apr 9 '16 at 8:45
  • @Kersten The output is this ERROR 1: --format option given with format 'hdf4', but that format not recognised. Use the --formats option to get a list of available formats, and use the short code (ie. GTiff or HFA) as the format identifier. – Soumya Apr 14 '16 at 12:54
  • @xunilk Not sure how to check whether or not QGIS is installed in Ubuntu. – Soumya Apr 14 '16 at 12:55
2

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.

  • You will be most definitely be able to use Python versions larger than 2.7.6 including Python 3.x – Kersten Apr 14 '16 at 13:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.