How to read wavelength information from envi file in spectral python libraray?

1.9k views Asked by At

I am working on hyperspectral imagery which is in envi format. I have successfully read it using spectral python library. Now , I want to get each band (wavelength center). Kindly suggest method for this task.

1

There are 1 answers

0
bogatron On

If you open the ENVI image with the spectral module, the wavelengths (band centers) are in the bands.centers attribute of the opened image.

>>> import spectral as spy
>>> img = spy.open_image('EO1H0150332002114111KZ.L1R.hdr')
>>> print(img.bands.centers[:5])
[355.59, 365.76, 375.94, 386.11, 396.29]

You can also get the raw header metadata from the metadata attribute of the opened image.

>>> print(img.metadata.keys())
dict_keys(['description', 'samples', 'lines', 'bands', 'header offset', 'file type', 'data type', 'interleave', 'sensor type', 'byte order', 'band names', 'read procedures', 'wavelength', 'fwhm', 'subset procedure'])
>>> print(img.metadata['wavelength'][:5])
['355.59', '365.76', '375.94', '386.11', '396.29']