I'm creating a spectral library in envi and I need to read this as an as array in python. I'm trying to use pysptools (pysptools.classification.SAM) package but i don't understand how to do this from the documentation.

sam.classify(M, E, threshold=0.1, mask=None)

M – numpy array A HSI cube (m x n x p).
E – numpy array A spectral library (N x p).

How to pass parameter E (I have spectral library created in ENVI)? Please Provide example if possible.


I'm reading ENVI spectral libraries using spectral

import spectral as sp1
import pandas as pd
SpecLib = sp1.envi.open('path to spectral library')
SpecLib_df = pd.DataFrame(index=SpecLib.names, data= SpecLib.spectra, columns=SpecLib.bands.centers)

Note that the path to your SpecLib should contain the folder+file+'hdr', for example:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.