我有来自PRISM Climate Group的降水数据,现在以.bil格式提供(我认为是ESRI BIL),我希望能够使用Python读取这些数据集。

我已经安装了spectral软件包,但是open_image()方法返回错误:

def ReadBilFile(bil):
    import spectral as sp
    b = sp.open_image(bil)
ReadBilFile(r'G:\truncated\ppt\1950\PRISM_ppt_stable_4kmM2_1950_bil.bil')
IOError: Unable to determine file type or type not supported.
Spectrum的文档明确表示它支持BIL文件,任何人都可以从中了解到这里发生的情况吗?我也愿意使用GDAL,它应该支持类似/等效的ESRI EHdr格式,但是我找不到任何好的代码片段来入门。

最佳答案

现在是2017年,还有一个更好的选择。软件包rasterio支持bil文件。

>>>import rasterio
>>>tmean = rasterio.open('PRISM_tmean_stable_4kmD1_20060101_bil.bil')
>>>tmean.affine
Affine(0.041666666667, 0.0, -125.0208333333335,
       0.0, -0.041666666667, 49.9375000000025)
>>> tmean.crs
CRS({'init': 'epsg:4269'})
>>> tmean.width
1405
>>> tmean.height
621
>>> tmean.read().shape
(1, 621, 1405)

关于python-2.7 - 使用Python读取压缩的ESRI BIL文件,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/23816545/

10-12 16:39