python - 如何使用光谱python处理多光谱栅格文件?

标签 python raster gdal geotiff spectral-python

我有兴趣使用 Spectral Python (SPy) 可视化和分类多波段栅格 GeoTIFF(非高光谱数据)。目前看来只有.lan.gis文件格式是可读的。

我尝试使用 gdal_translate 将文件转换为 .lan 但不支持图像格式( IOError: Unable to determine file type or type not支持).

知道如何将这个库用于非超光谱数据集吗?

最佳答案

将 GeoTIFF 文件转换为兼容格式(例如 LAN)。这可以通过两种方式之一来完成。在系统外壳中,使用 gdal_translate :

gdal_translate -of LAN file.tif file.lan

或在 Python 中类似:

from osgeo import gdal

src_fname = 'file.tif'
dst_fname = 'file.lan'
driver = gdal.GetDriverByName('LAN')

sds = gdal.Open(src_fname)
dst = driver.CreateCopy(dst_fname, sds)
dst = None  # close dataset; the file can now be used by other processes

请注意,第一种方法实际上更好,因为它还传输其他元数据,例如空间引用系统和可能的其他数据。要在 Python 中正确执行相同操作,需要添加更多代码行。

关于python - 如何使用光谱python处理多光谱栅格文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19785230/

相关文章:

r - 如何知道R中栅格中某个值出现的百分比?

r - 使用邻域分析填充栅格中 NA 值的间隙(例如,不是单个单元格)

Python:网格化点 X、Y 和 Z 以提取统计属性

python - 如何在生成样本时阻止 Azure TTS 播放音频?

Python:将对象存储在二维数组中并调用其方法

python - Pyinstaller 在 Windows 下的 onefile 可执行文件上出现 subprocess.check_output 问题

r - ggplot2:设置 alpha 值时,光栅绘图无法按预期工作

python - 如何使用 matplotlib-basemap 正确投影 tif 图像

python - 在 Python 中将 gdal_grid 与 np 数组一起使用

python - 通过python控制links2