Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This seems like it should be straightforward but I can't for the life of me figure it out.

Given an existing GeoTiff containing a single band, how can you add another band to that GeoTiff? Is the only way to do this to use GDALCreate() to create a new output file with an additional band and then copy the existing band from the original file to the new file? That's the only solution I've come up with so far but it just seems like there should be a simple way to add a band to the existing dataset.

share|improve this question
Hi @TheOx, I have a same problem. I want to make a composite image color from band 2,3,4 of LDCM single bands. Do you have solution for your question yet? – Jackie Jun 11 '14 at 9:32
@Jackie see kyle's comment in the accepted answer about using the vrt driver to create a copy, add a band, then create a copy of that back to a geotiff with the GeoTiff driver. – TheOx Jun 11 '14 at 13:50
up vote 5 down vote accepted

The solution, if the driver suuports it, is to call GDALOpen() with GA_Update access then use GDALAddBand or GDALDataset::AddBand. However, the geotiff driver doesn't support AddBand.

share|improve this answer
Very few drivers support add band, I don't believe the geotiff driver does. The only one I know that supports it is the vrt. – kyle Feb 1 '13 at 0:28
Well @kyle is right - the geotiff driver doesn't support AddBand, but the method in this answer is correct if the driver supports it and was what I was looking for so I'm accepting it. – TheOx Feb 1 '13 at 0:49
Doh! Forgot about that little detail. @TheOx I don't think you should accept my answer as it is not correct re. the orig question which specifically related to geotiffs. – Luke Feb 1 '13 at 2:46
@Luke: Edit your answer to specify that's the general solution if the driver supports it and I'll accept it. There appears to be no other way to do this for GeoTiff short of the method in my original question. – TheOx Feb 1 '13 at 14:53
Use the vrt driver, CreateCopy(), AddBand(), CreateCopy() with Geotiff Driver. – kyle Feb 1 '13 at 15:51

To expand on Luke's answer and provide a concrete example in Python, here's a snippet that adds an alpha band to a source raster and saves it as a PNG.

from osgeo import gdal

src_ds = gdal.OpenShared(input_path)
mask_ds = gdal.OpenShared(mask_path)
mask = mask_ds.GetRasterBand(1).ReadAsArray()

tmp_ds = gdal.GetDriverByName('MEM').CreateCopy('', src_ds, 0)

dst_ds = gdal.GetDriverByName('PNG').CreateCopy(output_path, tmp_ds, 0)
del dst_ds

I used the MEM driver instead of VRT since the latter does not support WriteRaster() and WriteArray() (error "Writing through VRTSourcedRasterBand is not supported."). Using the vrt driver might still be possible through some other methods, I suppose.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.