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