Struggling to compile gdal with hdf4 support

2019-07-23 18:10发布

问题:

I am unable to compile gdal with hdf4 support using bash on a mac osx el capitan version 10.11.6. I began with the homebrew approach to building gdal described on the osgeo website. Unfortunately, hdf4 is not by default supported by gdal. The hdf format page includes a great description of the hdf4 data structure but fails to help getting support for gdal. I've installed the szip, zlib, and jpeg libraries discussed here, and reviewed the struggles described by /u/dschneiderch here. The github thread lead me to a final link, which is the basis for my current post.

Using homebrew, I have installed hdf4 (brew install homebrew/versions/hdf4 returns a warning that versions was deprecated and homebrew will use science instead). I've been fighting with this gdal problem for a while, and sure enough, homebrew/science/hdf4-4.2.11_2 already installed. So, I linked hdf4 using brew link -overwrite-hdf4, and a warning comes back that it's already been linked.

I used brew remove gdal to start fresh with the install, then followed Shaun's approach in the sig-geo listserv to complete the gdal installation. Thus, my total workflow was:

brew tap homebrew/versions
brew install hdf4 
brew link --overwrite hdf4 
brew install gdal --complete --enable-unsupported --with-hdf4 

Unfortunately, even after linking the overwrite, I get a warning: Warning: gdal: this formula has no --with-hdf4 option so it will be ignored!. The installation continues, though, and homebrew is able to build gdal.

Checking gdalinfo --formats, hdf4 is still not included in the list. Any tips for what else to try?

回答1:

I've made some progress using this source, in that gdalinfo --formats' now includes HDF4 as a supported product. However, using pyModis to download data, I still pull a GDAL installation has no support for HDF4, please update GDAL` error.

Importantly, though, after installing Macport the following code works well for installing GDAL on Mac with HDF4 support:

 sudo port install gdal +hdf4 +hdf5 +netcdf