pythonpython-3.xsatellite-imagespectral-python

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


I have the following data available from the hyperspectral imaging:

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


Solution

  • 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.