Skip to content

Instantly share code, notes, and snippets.

@drewbo
Created March 12, 2015 18:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save drewbo/29af52e06e956a97ee1f to your computer and use it in GitHub Desktop.
Save drewbo/29af52e06e956a97ee1f 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