How to plot the NIR spectral signal from the hypercube data in python?

105 Views Asked by At

I have the following data available from the hyperspectral imaging:

  • cube_envi32.dat
  • cube_envi32.hdr
  • roi_masks.bmp

How can I plot the reflectance vs wavelength plot? Is there any sample python code that I can use?

1

There are 1 best solutions below

0
On BEST ANSWER

To plot an arbitrary pixel, you can use the spectral module to read the pixel data and wavelengths (assuming wavelength metadata are in the ENVI header):

import spectral as spy
import matplotlib.pyplot as plt

img = spy.envi.open('cube_envi32.hdr')
(i, j) = (10, 10) # coordinates of pixel to display
plt.plot(img.bands.centers, img[i,j])

If you want to plot spectra interactively, see the spectral documentation here.