Can someone tell me what I am doing wrong? I want to set bands 1 and three to 255, and band 2 to 0. The code below only should only set band 2, but gdalinfo shows that all bands get set to 0. Ubuntu 14.04, gdal 1.11.0. Thanks!
--------------------------------------
import sys
import os.path
import gdal
input = sys.argv[1]
dataset = gdal.Open( input, gdal.GA_Update )
if dataset is None:
print 'Unable to open', input, 'for writing'
sys.exit(1)
band = dataset.GetRasterBand(2)
band.SetNoDataValue(0.0)
band.FlushCache()
band = None
dataset = None
----------------------------------------------
$ gdalinfo test.tif
...
Upper Right (-11546254.150, 4881966.253)
Lower Right (-11546254.150, 4244288.152)
Center (-11950987.074, 4563127.202)
Band 1 Block=15107x1 Type=Byte, ColorInterp=Red
NoData Value=0
Band 2 Block=15107x1 Type=Byte, ColorInterp=Green
NoData Value=0
Band 3 Block=15107x1 Type=Byte, ColorInterp=Blue
NoData Value=0