I'm trying to open an MODIS file (hdf format) with gdal in a python script under windows OS. I use the HDF4 driver, as read at http://www.gdal.org/frmt_hdf4.html.
But when I run it I got this error message:

ERROR 4: `MOD10A1.A2000064.h12v04.005.2007164045648.hdf' not recognised as a supported file format. 

I have tried with the gdal.ALLRegister() statement with the same result. My goal is to obtain the properties of the image using GeoTransform, RasterXSize, etc. and reproject it afterward. If you could provide me with any help it would be much appreciated.

ps. I know I can use the Modis Reprojection Tool (MRT) but I need it to be included in my script as it will iterate over a folder containing a lot of images.


  • 2
    can you post the command you're using to get that error? also can you post the hdf's gdalinfo output?
    – nickves
    Commented Jul 23, 2013 at 20:20

2 Answers 2


HDF4 support is not available in GDAL by default. If you're using the GDAL binaries and python libraries from GISInternals, these do not have HDF4 support compiled in (at the time this answer was originally posted in July 2013, however HDF4 support was added to the GISInternal GDAL build in Nov. 2013). HDF4 support is compiled in the OSGeo4W GDAL binaries.

You can test if you have HDF4 support with the gdalinfo command: gdalinfo --format hdf4

You can also batch the MRT from within your python script using the subprocess module, see the "Command Line Interface" section of the MRT User Manual.

Edit: the subprocess module is easy to use, see below. See also the "Automated Batch Processing" section in the MRT User Manual.

import subprocess
def runcmd(cmd)
    proc = subprocess.Popen(cmd, stdout=subprocess.PIPE,stderr=subprocess.PIPE)
    return exit_code,stdout,stderr

cmd = 'mrt command line'
exit_code,stdout,stderr = runcmd(cmd)
if exit_code:raise RuntimeError(stderr)
else:print stdout
  • Thank for your answer. However, I'm kind of new to python and after searching the net, the subprocess module use seems too complex. I have downloaded the osgeo4W installer on the link you provide. I don't know if I missed something but there is no .py file in it!
    – GuillaumeD
    Commented Jul 24, 2013 at 18:28
  • The installer provides options for installing the components that you want. Under "command line" you'll see python, and if you (optionally) install it "python" is available in the OSGeo4W shell.
    – mdsumner
    Commented Jul 24, 2013 at 20:26
  • @GDesbiens, see edit to answer above.
    – user2856
    Commented Jul 24, 2013 at 21:20
  • in which 'cmd' would be my MRT command line function ?
    – GuillaumeD
    Commented Jul 24, 2013 at 21:31
  • 1
    @Glorfindel, thanks for the fixing the link rot!
    – user2856
    Commented Sep 9, 2022 at 23:13

gdal_HDF4.dll and gdal_HDF4Image.dll should be on your GDAL driver path. Another reason may be a conflict of GDAL driver paths, for example, another version of GDAL and paths related to it may be installed on your system (such as GDAL in Python packages) that does not contain the mentioned dlls.

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.