I'm interested in using Spectral Python (SPy) to visualize and classify multiband raster GeoTIFF (not hyperspectral data). Currently it appaers that only .lan, .gis File Formats are readable.

I've tried to convert files to .lan with gdal_translate but the image format is not supported( IOError: Unable to determine file type or type not supported).

Any idea how to use this library for non hypersperctral dataset?

有帮助吗?

解决方案

Convert the GeoTIFF file to a compatible format (e.g. LAN). This can be done in one of two ways. From a system shell, use gdal_translate:

gdal_translate -of LAN file.tif file.lan

Or similar within 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

Note that the first method is actually better, as it also transfers other metadata, such as the spatial reference system and possibly other data. To correctly do the same in Python would require adding more lines of code.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top