py-gdalogr-cookbook icon indicating copy to clipboard operation
py-gdalogr-cookbook copied to clipboard

GDAL Create Raster Dataset mistake

Open ustroetz opened this issue 11 years ago • 0 comments

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.

ustroetz avatar Feb 25 '14 20:02 ustroetz