I am trying to open and read a hyperspectral image using GDAL like below.

So after reading the data like this :

data = gdal.Open( filename )

then I can see the x, y, dim information of the dataset :

x = data.RasterXSize
y = data.RasterYSize
dim = data.RasterCount

Now the question is that if there is any way to find out that each band wavelength from image.? I have the following data image: sub_66 Type:File sub_66 Type:hdr sub_66 Type:aux(xml) This data file is of AVIRIS(Hyperspectral Data) sensor.

  • 1
    This is not a duplicate; I believe the question is how to retrieve the wavelength of each band in a hyperspectal image. I do not know the answer, but I this information is not part of the standard gdal data model. So if it is present it will be accessed through the metadata, I believe for envi hyperspectral images this information (if present) is in the hdr file. Commented Feb 27, 2017 at 19:16
  • Could you please update your post to include the sensor you are working with (e.g. AVIRIS, Landsat8 OLI, Worldview-3, etc).
    – Aaron
    Commented Feb 28, 2017 at 1:56

2 Answers 2


What you need to do is parse the 'fmmyyddtnnpnnrnnrdn_v_.spc' file associated with your dataset. Each line in that file corresponds to a band in your image.
First column in the file is the 'Wavelength Center Position' and the second column is 'Full Width at Half Maximum', meaning the bandwidth. It should be noted that there may be more than two columns, depending on the scene.
With those two pieces of information, you should have what you need.

The same information can also be found in the associated hdr-file, from which it can be parsed by treating the file as a standard text-file. From there, you can combine the information using standard functions in Python.
The way the additional information is presented in the hdr-file is not supported by gdal and as such, you'll have to create your own approach for this.

  • But,I don't have a such file( 'fmmyyddtnnpnnrnnrdn_v_.spc') Commented Mar 1, 2017 at 1:46
  • @PruthviPatel - do you have any files other than the image? Commented Mar 1, 2017 at 9:14
  • Yes,I have hdr extension file. Commented Mar 1, 2017 at 14:51
  • @PruthviPatel - so you only have two files? Commented Mar 1, 2017 at 14:59
  • Yes,hdr extension file contain wavelength.but how to access it(usin gdal) i don't know. Commented Mar 1, 2017 at 15:12

As others have mentioned, wavelengths aren't part of the standard data model so for data in ENVI format it is best to extract from the associated '.hdr' file separately, which is just a text file and often contains more information than GDAL reads.

I wrote a library to read ENVI header files in Python which is availble from https://github.com/pmlrsg/arsf_tools. The library parses the .hdr file and saves all the fields to a dictionary. Using this library (or something similar) you could extract the wavelengths from the header file using:

import numpy
from arsf_envi_reader import envi_header

in_header = envi_header.find_hdr_file("Input_envi_file")
header_data = envi_header.read_hdr_file(in_header)

# Get wavelengths and convert to NumPy array
wavelengths = header_data['wavelength'].split(',')[0:-1]
wavelengths = [float(w) for w in wavelengths]
wavelengths = numpy.array(wavelengths)

For some sensors FWHM is also stored in the header file and can be extracted in a similar way.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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