5

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

4
  • Do you have QGIS in Ubuntu? The *.hdf support it would be installed.
    – xunilk
    Commented Apr 8, 2016 at 12:02
  • In a bash what is the result of gdalinfo MYD06_L2.A2014002.0645.006.2014269075802.hdf and gdalinfo --formats?
    – Kersten
    Commented Apr 9, 2016 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
    Commented Apr 14, 2016 at 12:54
  • @xunilk Not sure how to check whether or not QGIS is installed in Ubuntu.
    – Soumya
    Commented Apr 14, 2016 at 12:55

1 Answer 1

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.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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