将conda HDF4链接到conda GDAL(Anaconda Python)

3 投票
1 回答
1454 浏览
提问于 2025-04-18 17:27

我通过Anaconda安装了Python,平时用它做一些常规的事情都没问题。不过,我需要打开一个MODIS HDF4-EOS文件。我尝试过以下几种方法:

conda install -c https://conda.binstar.org/mutirri hdf4

conda install gdal

python -c "from osgeo import gdal; ds=gdal.Open("MOD021KM.A2014005.0910.006.2014005194151.hdf"); print type(ds)"

但是我得到了这个错误:

错误 4: `MOD021KM.A2014005.0910.006.2014005194151.hdf' 这个文件格式不被支持。

< 类型 'NoneType' >

嘿……看起来是可行的。

有没有人知道如何在使用Anaconda的Python 2.7中,用GDAL打开HDF4文件?如果能帮我解决这个问题,我会非常感激。

谢谢大家。

1 个回答

3

虽然你的问题和这个问题不完全一样 https://gis.stackexchange.com/questions/110662/install-gdal-in-centos-without-root,但你可以参考接受的答案中的方法:

conda update conda
conda update anaconda
conda install -c https://conda.binstar.org/jgomezdans gdal=1.11.0

这个来自binstar的GDAL版本支持HDF4,并会自动安装conda的HDF4包。在安装新版本之前,最好先把你已经安装的GDAL和HDF4包删除掉。

撰写回答