2

I'm running code that works with MODIS HDF4 datasets on a Debian Linux distribution. I am also running this code on a Windows machine. On both the Windows and the Linux machines, I have the most recent GDAL version (gdal 1.11.1, np19py27_1), however on the Linux machine, GDAL doesn't seem to recognize HDF4 Drivers... it won't load or process any of the HDF4 datasets that are easily processed on the Windows machine (unfortunately this machine doesn't have enough space to run the full code).

Has anyone else encountered this problem? Do I need to install an additional module on the Linux system?

1
  • Have you compiled gdal from source? What version of debian are you using? What version of hdf4? What compilation options? If this is happening with the gdal version provided by debian, please mail the debian-gis mailinglist or file a bug against hdf4 or gdal. If possible, provide a link to the file.
    – johanvdw
    Commented Mar 2, 2015 at 8:24

3 Answers 3

2

On Debian, you'll have to install libhdf4-alt-dev (not libhd4-dev) and then re-compile gdal.

But there's a conflict with NETCDF if those drivers are enabled, so it's important to disable netcdf during the compile:

./configure --disable-netcdf --disable-fortran

And it should find the hdf4 libs automatically.


UPDATE

There was a recent post on the GDAL mailing list from Jose who posted some instructions on his blog to getting HDF4 support in GDAL 1.11.2 for anaconda:

wget http://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh bash ./Miniconda-latest-Linux-x86_64.sh export PATH=/opt/anaconda/bin:$PATH conda install numpy scipy matplotlib ipython ipython-notebook conda-build conda install scikit-learn pandas spyder numba numexpr cython binstar conda install -c https://conda.binstar.org/jgomezdans proj4 conda install -c https://conda.binstar.org/jgomezdans hdf4 conda install -c https://conda.binstar.org/jgomezdans gdal conda install geos

Reference: https://trac.osgeo.org/gdal/wiki/HDF
Reference: http://jgomezdans.github.io/new-version-of-gdal-packages-with-hdf-for-anaconda.html

4
  • If I install libhdf4-alt-dev on Debian via aptitude does it automatically disable netCDF? The instructions at the link you gave make it seem like you only need to disable netCDF and Fortran if building manually. Do need to disable netCDF and Fortran when installing with aptitude? At present, libhdf4-alt-dev is installed along with most recent GDAL and python script HDFs are still not recognized as supported file format.
    – Emily
    Commented Feb 18, 2015 at 21:39
  • I'm guessing you'll have to recompile GDAL yourself because I think if you can't access HDF4 files from the get go suggests GDAL isn't compiled with that driver, so you'll have to compile it from source. There are some directions on the Debian wiki at wiki.debian.org/BuildingTutorial
    – SaultDon
    Commented Feb 18, 2015 at 22:33
  • I'm working with Anaconda and installed GDAL using conda install gdal. Do I need to rebuild outside of Anaconda? And even then, would Anaconda even recognize the rebuilt GDAL?
    – Emily
    Commented Feb 18, 2015 at 22:49
  • @Emily I'm not sure, never used conda/anaconda. But I think you would have to build the gdal python bindings in conda. This link might help and give some hints on how to do that: conda.pydata.org/docs/build_tutorials/postgis.html
    – SaultDon
    Commented Feb 19, 2015 at 1:37
2

I had the same issue and I would like to share my solution to the problem :

  1. First make sure that you have the necessary hdf4 drivers installed:

    apt-get install libhdf4-dev
    apt-get install proj-bin
    apt-get install libproj-dev
    apt-get install libgdal-dev
    apt-get install gdal-bin     # Thanks to user @mdsumner for this
    
  2. Then there seems to be a issue with the pyModis package itself as explained by Luca here: https://github.com/lucadelu/pyModis/issues/29#issuecomment-104800294

    So I removed pymodis and installed the new version directly form the Github site, run the following command

    sudo pip git+https://github.com/lucadelu/pyModis.git
    

And then to be sure run an upgrade and then the HDF4 problem should be gone when you import pymodis.

0

The answer of SaultDon is right. You have to install libhdf4-alt-dev. HDF4 contains an old version of netcdf which is disabled in this package. This is disabled in that package because it clashes with more recent versions of netCDF. Since GDAL uses the headers of the recent version of CDF you have to use the -alt- version. This will not disable netCDF support, as the recent version is used.

The gdal version in Debian should actually already support hdf4 out of the box. If you compile from source, make sure you use the --with-netcdf option.

You don't mention what version of debian you use, but I just want to point out that there is a very recent gdal version in experimental. You may consider building that for your version of debian. This is only needed if you really need the last version of GDAL. The version provided with debian should provide HDF4 out of the box (please file a bug if it doesn't).

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.