4

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?

bogatron
  • 18,639
  • 6
  • 53
  • 47
Wraf
  • 747
  • 2
  • 10
  • 24
  • Why do you want to use a module for processing hyperspectral image data for data that is not hyperspectral image data? – Mailerdaimon Nov 05 '13 at 09:16
  • @Mailerdeamon: Multispectral dataset (i.e. 36 bands files such as MODIS dataset) is similar to hyperspectral dataset for visualization and classification tool (but the spectral window of acquisition of the multispectral sensors are not sampled in a regular basis such as the hyperspectral sensors) – Wraf Nov 05 '13 at 09:35
  • 1
    Ok. You should be able to convert `GeoTIFF` to `ENVI`(which is supported by SPy) using `gdal_translate`. If there is an error your files might be corrupted or something in your header is wrong for gdal. – Mailerdaimon Nov 05 '13 at 09:47

1 Answers1

3

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.

Mike T
  • 41,085
  • 18
  • 152
  • 203