7

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. – lpd2 Feb 27 '17 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 Feb 28 '17 at 1:56
1

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') – Pruthvi Patel Mar 1 '17 at 1:46
  • @PruthviPatel - do you have any files other than the image? – Mikkel Lydholm Rasmussen Mar 1 '17 at 9:14
  • Yes,I have hdr extension file. – Pruthvi Patel Mar 1 '17 at 14:51
  • @PruthviPatel - so you only have two files? – Mikkel Lydholm Rasmussen Mar 1 '17 at 14:59
  • Yes,hdr extension file contain wavelength.but how to access it(usin gdal) i don't know. – Pruthvi Patel Mar 1 '17 at 15:12
1

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, privacy policy and cookie policy

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