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:
If you need a pythonic solution I would suggest looking at rasterio.
that should show you the bands, or you can assign them to a variable if desired.