GeoTIFF – How to Read the Wavelength of Each Channel in a UAV .tif Image

geotiff-tiff

I have a UAV .tif image, but I cannot figure out which channel is which color. I tried this code: https://automating-gis-processes.github.io/2016/Lesson7-read-raster.html which also doesn't help. More specifically at this point of the code:

# Read the raster band as separate variable
band = raster.GetRasterBand(1)

# Check type of the variable 'band'
type(band)

I did this:

print(band)

which prints this:

<osgeo.gdal.Band; proxy of <Swig Object of type 'GDALRasterBandShadow *' at 0x7f5de576f930> >

and not wavelength in nm.

I need to do something like this: Determining which "color" each image band represents? but not for satellite image, but for UAV 3-channel or 4-channel RGB .tif image..

Any idea?

Best Answer

What you're looking for is the metadata of the raster. I prefer GDAL's command line tool gdalinfo, which is really good when you know all the rasters have the same metadata:

gdalinfo UAV.tif

If you need a pythonic solution I would suggest looking at rasterio.

import rasterio

with rasterio.open('UAV.tif') as src:
    meta_profile = src.meta

print(meta_profile)

that should show you the bands, or you can assign them to a variable if desired.