I have a multi-band HDF file that I want to convert to a single GeoTiff file, using free tools, preferably gdal. I'm trying to use gdal_translate, but I either get back multiple output .tif files, or I get "subdatasets" errors.

When I use the -b flag to specify bands:

gdal_translate -b 1 -b 2 -of GTiff input_image.hdf output_image.tif

I get "subdatasets" errors: "Input file contains subdatasets. Please, select one of them for reading."

And when I use the sds flag:

gdal_translate -sds -of GTiff input_file.hdf output_file.tif

I get back separate .tif files, one for each band in the input file.

How can I convert an HDF file into a single GeoTiff file using gdal?


If you want to extract one band (subdataset) from your HDF file, than you need to specify the SUBDATASET name as part of the gdal_translate command. For instance, in the example described here, it is suggested to do the following:

gdal_translate HDF4_SDS:UNKNOWN:"AMOD021KM20061229043102.hdf":0 test_b0.tif

gdal_translate HDF4_SDS:UNKNOWN:"AMOD021KM20061229043102.hdf":1 test_b1.tif

You will need to update HDF4_SDS:UNKNOWN:"AMOD021KM20061229043102.hdf to reflect your own dataset, and you can retrieve this information using gdalinfo.

Also, the documentation on the GDAL website relating to the HDF format provides a lot of useful information and examples that should further assist you.

  • Thanks for responding. I am trying to convert all of the bands/subdatasets from HDF format to GeoTiff. – the_cat_lady Dec 6 '16 at 19:45

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.