[GIS] how to rename the band-names of a layer stack

gdal-mergeqgisrasterstack

I created a layer stack of 20 images (all GTiff-files) using the gdal_merge tool in QGIS, available at:

raster > miscellaneous > merge

The result is a GTiff layer stack of the 20 images, but the band names are band1, band2, band3…band20, looking at the properties.

Is there a way to rename the band-names, either afterwards, or during creation of the stack?

They are all from different sensors/dates and will be more meaningful to work with other names than band1,band2,band3.

Thanks!

Best Answer

I also needed to know how to rename bands in an open source environment so spent a whole day looking for answers.

There is no way to name bands in QGIS while merging.

But it can be done after the file is created, by editing their .aux.xml file. It works for both .tif and .img files, as far as I've researched.

The solution is to include after each <PAMRasterBand band="1">, <PAMRasterBand band="2">, etc, a subelement <Description>YourBandName</Description>. I haven't tested it for VRT datasets, but the link at the end suggests that it should be the same procedure.

In ArcMap, you will be able to see the new names in the Properties > Symbology window, when setting your colour composite, also in Table of Contents, under your image layer.

In QGIS, I suspect there is a bug, and this will not work. However, you can still label your bands in a more indirect way by also including after the element the subelement:

<Metadata>
   <MDI key="Band">YourBandName</MDI>
</Metadata>

This will show up in the Properties > Metadata tab, for each individual band.

Example image attached, only first band was named for demonstration. Checked on ArcMap on Windows and QGIS in Ubuntu.

Sources: http://lists.osgeo.org/pipermail/gdal-dev/2013-October/037321.html

enter image description here