py-gdalogr-cookbook
py-gdalogr-cookbook copied to clipboard
GDAL Create Raster Dataset mistake
In several recipes I used the wrong arguments in the GDAL create function. The documentation for function can be found here.
I always mixed up the number of bands with the GDALDataType. For instance I wrote
outRaster = driver.Create(newRasterfn, cols, rows, gdal.GDT_Byte)
But it needs to be
outRaster = driver.Create(newRasterfn, cols, rows, numberBands, gdal.GDT_Byte)
Most of the time this doesn't cause any problems. But when you actually want to assign another GDALDataType or more than one band, then it does matter.