spectralpython / spectral

Python module for hyperspectral image processing
MIT License
573 stars 139 forks source link

Bug reading ENVI SLI files using spectral.io.envi.open() #36

Closed jaypops96 closed 9 years ago

jaypops96 commented 9 years ago

I'm using python 2.7.6, and discovered what I think is a bug reading ENVI SLI (spectral library) files. Every time I try to read SLI files it bombs on me, I think because envi.open() is mistakenly accessing the .sli (data) file when it tried to read header data, rather than accessing the .hdr file (header).

A single-line addition(shown below) at the beginning of the spectral.io.envi.open() function should be sufficient to fix this problem.

import os
   from .spyfile import find_file_path
   import numpy
   import spectral

   headerPath = find_file_path(file)                   (This line should be removed)
   headerPath = os.path.splitext(file)[0]+'.hdr'   (this new line should replace the line above)
   h = read_envi_header(headerPath)

jaypops96 commented 9 years ago

I withdraw this issue. In IDL/ENVI it's customary to select the data file, rather than the HDR file, when opening. In spectralPy, you are asking for the HDR file to be selected when opening a data file. That was my source of confusion -- it works fine when you input the HDR file, i.e. open(HEADER_filename)