I can open and read a hyperspectral image using GDAL according to the instructions brought by Max König here:
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 is actually representing what electromagnetic spectrum?
After reading all bands as a list in python like this:
RasterBands =[]
for i in range(data.RasterCount):
RasterBands.append(data.GetRasterBand(i))
I can write:
RasterBands[1].ComputeBandStats()
This will give me two float values, but I am not sure if they are representing the wavelengths of band 1 or not.
Would be thankful if anyone can give me a clue!
Best
Sina
Best Answer
As @user30184 says, gdal is just reading the values of your raster band, but you should be able to know the wavenlenght of each band based on the metadata (information you should get about the data).
the two values returned by "ComputeBandStats()" will be the mean and standard deviation of the values in your bands. If the mean value is between zero and one, you can assume that your data stores the reflectance, otherwise the values are probably digit numbers.
Usually, hyperspectral data have a very large number of bands (several hundreds) with a constant sampling interval in the wavelengths (e.g. 6 nm), so if you know the value of the wavelength range (e.g. 400-900 nm), you can derive the central wavelength of each bands using a rule of 3.