一、前言
HDF也是一种自描述格式文件,主要用于存储和分发科学数据。气象领域中卫星数据经常使用此格式,比如MODIS,OMI,LIS/OTD等卫星产品。有两种HDF格式,HDF4和HDF5,每种格式都有自己的库和驱动程序。HDF4更常见,但HDF5是下一代格式。[(https://trac.osgeo.org/gdal/wiki/HDF)]
gdal默认不支持HDF影像数据的读取,需要自行编译。
如何编译
- 下载HDF4、HDF5库(Download the HDF library from the official website (https://www.hdfgroup.org/downloads/hdf4/).)
- 根据您的操作系统,编译并安装HDF库。
- 修改gdal编译文件(namke.opt文件)
- 编译gdal c++版本
- 编译gdal c#版本
二、修改gdal编译文件
修改支持HDF4
修改nmake.opt文件439-448行如下 :
#Uncomment the following and update to enable NCSA HDF Release 4 support.
HDF4_PLUGIN = NO HDF4_DIR = F:\02-learn\gdal\3part64\hdf4\x64 HDF4_LIB
> = $(HDF4_DIR)\lib\hdf.lib $(HDF4_DIR)\lib\mfhdf.lib Ws2_32.lib HDF4_INCLUDE = $(HDF4_DIR)\include
> # HDF4 library newer than 4.2.5 has a SDreset_maxopenfiles/SDget_maxopenfiles
> # interface which allows opening many HDF files simultaneously (the max
> # number of files was previously hardcoded and too low, smth. like 32).
> # Uncomment following if your library is newer than 4.2.5. HDF4_HAS_MAXOPENFILES = YES
修改支持HDF5
修改nmake.opt文件450-453行如下:
#Uncomment the following and update to enable NCSA HDF Release 5 support.
HDF5_PLUGIN = NO
HDF5_DIR = F:\02-learn\gdal\3part64\hdf5\x64
HDF5_LIB = $(HDF5_DIR)\lib\hdf5.lib
三、编译GDAL
gdal编译参考文章c#版gdal。