GDAL and HDF4 files for conversion to .tif - in R or elsewhere

:wave: Hello !

I have a problem on which I have been banging my head for the past few days - putting it here to see if someone may have a solution or alternative in mind…

I need to use some remotely sensed data (Temperature data) from MODIS. The data are provided (found on EarthExplorer) as HDF-EOS format, which, If I understood correctly, is a peculiar format, closer to the HDF4 old format, quite different from the HDF5 format that is more commonly used,

I need to read those .hdf files, get the subdatasets of interest and then convert them to .tif for analysis, handling etc… I did this in 2019 directly from R using the {terra} and {gdalUtils} packages and it somehow worked.

However I have changed my computer, and reinstalled GDAL, and it is not the case anymore - my understanding is that the latest GDAL version do not support HDF4 format by default anymore (rather support HDF5) and the GDAL version installed from homebrew (I work on Mac) confirmed it as HDF4 is not listed in the supported formats.

Therefore my questions:

  1. How can I add the HDF4 library to my homebrew version of GDAL ?
  2. If above is not possible, how can I get a version of GDAL that supports HDF4 on my Mac ?
  3. If nothing of the above is a potential solution, which tool can I use to convert my HDF4 to .tif ? I thought of QGis but I have to read the file from the terminal which of course uses GDAL…

Not sure if everything is clear, but let me know if anyone has come upon this problem and might have a solution ? Haven’t found anything yet…will mark a solution if I do find one

1 Like

@ChrisJ @avaughan @castory any ideas?

1 Like

Alright so never managed to find a solution through R or GDAL - I abandoned that path and went down to download and install the HDF-EOS to GEOTIFF conversion tool (HEG). It was painful but it did the work to convert all the HDF to usable .tiff files !

If anyone read this and found a solution don’t hesitate to share :open_hands:t3: I go back to my .tif files !!

3 Likes