You can use a simple python script that uses the Band.SetDescription method to set the band names:
"""
Set Band descriptions
Usage:
python set_band_desc.py /path/to/file.ext band desc [band desc...]
Where:
band = band number to set (starting from 1)
desc = band description string (enclose in "double quotes" if it contains spaces)
Example:
python set_band_desc.py /path/to/dem.tif 1 "Band 1 desc" 2 "Band 2 desc" 3 "Band 3 desc"
"""
import sys
from osgeo import gdal
def set_band_descriptions(filepath, bands):
"""
filepath: path/virtual path/uri to raster
bands: ((band, description), (band, description),...)
"""
ds = gdal.Open(filepath, gdal.GA_Update)
for band, desc in bands:
rb = ds.GetRasterBand(band)
rb.SetDescription(desc)
del ds
if __name__ == '__main__':
filepath = sys.argv[1]
bands = [int(i) for i in sys.argv[2::2]]
names = sys.argv[3::2]
set_band_descriptions(filepath, zip(bands, names))
This functionality should probably be in gdal_edit, but isn't.
For example:
gdalbuildvrt -separate test.vrt test2015.tif test2016.tif test2017.tif
0...10...20...30...40...50...60...70...80...90...100 - done.
gdalinfo test.vrt
Driver: VRT/Virtual Raster
<snip...>
Band 1 Block=128x128 Type=Byte, ColorInterp=Undefined
Min=1.000 Max=1.000
NoData Value=0
Band 2 Block=128x128 Type=Byte, ColorInterp=Undefined
Min=1.000 Max=1.000
NoData Value=0
Band 3 Block=128x128 Type=Byte, ColorInterp=Undefined
Min=1.000 Max=1.000
NoData Value=0
python set_band_desc.py test.vrt 1 2015 2 2016 3 2017
gdalinfo test.vrt
Driver: VRT/Virtual Raster
<snip...>Band 1 Block=128x128 Type=Byte, ColorInterp=Undefined
----> Description = 2015
Min=1.000 Max=1.000
NoData Value=0
Band 2 Block=128x128 Type=Byte, ColorInterp=Undefined
----> Description = 2016
Min=1.000 Max=1.000
NoData Value=0
Band 3 Block=128x128 Type=Byte, ColorInterp=Undefined
----> Description = 2017
Min=1.000 Max=1.000
NoData Value=0