Skip to content

Instantly share code, notes, and snippets.

@jqtrde
Forked from drewbo/gdal_hdf.md
Last active August 29, 2015 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jqtrde/5b0ee9d00289ce595198 to your computer and use it in GitHub Desktop.
Save jqtrde/5b0ee9d00289ce595198 to your computer and use it in GitHub Desktop.

MODIS downloads are stored as .hdf files which makes them non-trivial to interact with.

I've previously mentioned using HEG but for a more streamlined approach we're going to want to use gdal.

Compiling GDAL with HDF4 support can actually be done fairly easily using brew although information on this was a bear to find. Thanks to Wood Sun we can do this via three commands

brew tap homebrew/versions
brew install hdf4
brew install https://raw.githubusercontent.com/geoalchimista/homebrew/master/formulae/gdal.rb --with-hdf4

On first view, the github code display hides the most important part: the third line ends with --with-hdf4. This will compile GDAL with support for HDF4 (and makes the installation take much longer). Note that the default homebrew formula for GDAL does NOT contain the --with-hdf flag so it won't do anything if you try this with just brew install gdal.

Verify you've done everything correctly by running:

gdalinfo --formats | grep HDF

and you should see:

HDF4 (ros): Hierarchical Data Format Release 4
HDF4Image (rw+): HDF4 Dataset
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment