I'm on OSX 10.9.4, using GDAL 2.0.1 from the terminal. I want to mosaic MCD12Q1 HDFs together with GDAL but my build can't even read them.

The file: http://e4ftl01.cr.usgs.gov/MOTA/MCD12Q1.051/2001.01.01/MCD12Q1.A2001001.h00v08.051.2014287161513.hdf

Trying to gdalinfo that file:

gdalinfo failed - unable to open 'MCD12Q1.A2001001.h20v13.051.2014287163801.hdf'.

gdalinfo --formats shows that my build supports:

      HDF5 -raster- (ros): Hierarchical Data Format Release 5
      HDF5Image -raster- (ro): HDF5 Dataset

So I assume these MODIS HDFs are using the HDF4 standard, which isn't listed in my formats list, and that's why GDAL has no idea what to do with them.

My QGIS Essen 2.14.0 says it's running against GDAL 1.11.4, which can't read them either; I add the HDF and it asks me to pick a raster layer in the file, but when I select one nothing appears and the error log says "Unable to load."

I saw this question about the same issue on Windows, but apparently HDF4 support is an optional flag when you install GDAL? Anyone else have this issue with MODIS HDFs on OSX? Is there a way to get HDF4 support into my GDAL builds? I installed both GDAL and QGIS using KyngChaos's installers.

EDIT: QGIS would not load these HDF4 files because their directory path had quote marks " in it. Moving them to a directory without quotes fixed this.

2 Answers 2


I think you have a big problem of paths. The version of QGIS of KynChaos installs GDAL as a Framework in /Library/Frameworks/GDAL.framework

If I use this version (1.11.4)

 /Library/Frameworks/GDAL.framework/Versions/1.11/Programs/gdalinfo --format hdf4
 Format Details:
 Short Name: HDF4
 Long Name: Hierarchical Data Format Release 4
 Extension: hdf
 Help Topic: frmt_hdf4.html
 Supports: Subdatasets

Therefore, the format is supported and

/Library/Frameworks/GDAL.framework/Versions/1.11/Programs/gdalinfo  MCD12Q1.A2001001.h00v08.051.2014287161513.hdf
Driver: HDF4/Hierarchical Data Format Release 4
Files: MCD12Q1.A2001001.h00v08.051.2014287161513.hdf
Size is 512, 512
Coordinate System is `'
.... (many lines)
  SUBDATASET_1_DESC=[2400x2400] Land_Cover_Type_1 MOD12Q1 (8-bit unsigned integer)
  SUBDATASET_2_DESC=[2400x2400] Land_Cover_Type_2 MOD12Q1 (8-bit unsigned integer)
  SUBDATASET_16_DESC=[2400x2400] LC_Property_3 MOD12Q1 (8-bit unsigned integer)
Corner Coordinates:
Upper Left  (    0.0,    0.0)
Lower Left  (    0.0,  512.0)
Upper Right (  512.0,    0.0)
Lower Right (  512.0,  512.0)
Center      (  256.0,  256.0)

And in QGIS, I have no problem to open a layer.

enter image description here

But the layer itself is problematic because when you use it with the Modis Reprojection Tool (conversion to Geotiff) the images are only black and white (2 colors, 0 and 255)

enter image description here

  • You're right, it is a PATH problem. Commented Mar 18, 2016 at 18:04
  • My /Library/Frameworks/GDAL.framework/Versions/ shows I only have 1.11, which is weird because gdalinfo in terminal reports that I have 2.0.1, but it's because I use Enthought Canopy and I had installed 2.0.1 in Enthought's package manager. My terminal defaults to using Enthought's paths to everything. Even downgrading to 1.11.2 in Enthought's package manager doesn't work, since their build of 1.11.2 has no HDF4 support. BUT if I specifically call gdalinfo found in /Library/Frameworks/GDAL.framework/Versions/1.11/Programs/, that version is 1.11.4 and supports HDF4. Commented Mar 18, 2016 at 18:11
  • Change the paths in your ~/.bash_profile file. (I don't use the Enthought distribution but the Apple Python and the Anaconda Scientific Python distribution, totally independent of the Apple Python
    – gene
    Commented Mar 20, 2016 at 20:17

I ran into this problem with multiple versions of GDAL installed.

I solved it by specifying the full path to my homebrew installed GDAL 1.11.5

e.g. instead of gdalinfo 'MCD12Q1.A2001001.h20v13.051.2014287163801.hdf'

I used /usr/local/bin/gdalinfo 'MCD12Q1.A2001001.h20v13.051.2014287163801.hdf'

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.