[Gdal-dev] gdaldataset writeraster
Gong, Shawn
Shawn.Gong at drdc-rddc.gc.ca
Mon Jan 22 16:56:36 EST 2007
Hi list,
I open a gdaldataset, have done manipulation to r,g,b and nir bands.
Now I'd like to save the 4 bands back to original gdaldataset or a new
dataset.
Can't seem to get gdaldataset's WriteRaster() working, or is it the
right method?
Please help.
fname1 = 'file3.tif'
msi_dataset = gdal.Open(fname1)
msi_array = msi_dataset.ReadAsArray()
r = msi_array[:][:][0]
g = msi_array[:][:][1]
b = msi_array[:][:][2]
nir = msi_array[:][:][3]
row = msi_dataset.RasterYSize
col = msi_dataset.RasterXSize
the following I am not sure:
msi_dataset.WriteRaster(0, 0, col, row, r, col, row,
Numeric.Float16, [0])
msi_dataset.WriteRaster(0, 0, col, row, g, col, row,
Numeric.Float16, [1])
msi_dataset.WriteRaster(0, 0, col, row, b, col, row,
Numeric.Float16, [2])
msi_dataset.WriteRaster(0, 0, col, row, nir, col, row,
Numeric.Float16, [3])
Thanks,
Shawn Gong
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20070122/2eedee5c/attachment.html
More information about the Gdal-dev
mailing list