For this I will walk through a method of renaming raster bands for GTIFF file format images.
Generating a Metadata File:
To start off, if you raster file does not have a metadata file, often with a file format ‘.aux.xml’, then we will need to generate one. This can be done in two ways:
- Open QGIS 3.x, and load you raster file.
- Navigate to ‘Raster > Miscellaneous > Raster Information‘
- Select ‘Read and display image statistics’
Or, if you are familiar with the command line, then you can simply utilise the gdalinfo command specifying your file you want to generate the metadata for, like below:
$ gdalinfo -stats 'MyFile.tif'
If you don’t have the GDAL package installed on your machine, then you can install it via an Conda environment using the following:
$ conda install gdal
You can learn more about Anaconda, and setting up computer environments through this link: Anaconda | Individual Edition
Editing the Metadata File:
Your metadata file when opened in your prefered text editor will look like something similar:
The solution is to include a subelement within your metadata specifying the raster band name. This is inputted just after the band name and description, like below:
< MDI key="Band">YourBandName</MDI>
When compared to the above image of the metadata file, it can be seen that Raster Band 1 has been labelled as Blue.
So now you know how to rename raster bands!
Thanks for reading!