[gdal-dev] Potential bug with the create function for the "GTiff" driver

Adeel Raza adeel.raza at crc.gc.ca
Thu Jul 9 09:47:58 EDT 2009


I'm using gdal 1.6.1 for MSVC9.0 on Windows XP (32-bit platform). I'm 
trying to create a .tif file according to the following code:

    GDALDriver *tifDriver;
    GDALDataset *srcDataset;

    tifDriver = (GDALDriver *)GDALGetDriverByName("GTiff");
    assert(tifDriver != NULL);
    srcDataset = tifDriver->Create("srcDataset.tif", nCols, nRows, 1, 
GDALDataType::GDT_Float32, NULL);
    assert(srcDataset != NULL);

"nCols" is defined as an unsigned short and has a value of 2460. 
Similarly "nRows" is also defined as an unsigned short and has a value 
of 2430.
When I run the code shown above the asserts do not fail. The returned 
dataset however, has wrong values assigned to its data members. The 
values for the data members of "srcDataset" are as follows:

eAccess = 2460;
nRasterXSize = 2430;
nRasterYSize = 1;
nBands = 19035560;
papoBands = 0X00000000;
bForceCahcedIO = 1
nRefCount = 0;
bShared = 0;

The values for nRasterXSize, nRasterYSize, and nBands are wrong (I'm not 
sure about the other data members), and should be as follows:
nRasterXSize = 2460;
nRasterYSize = 2430;
nBands = 1;

Is this a bug in the create function for the "GTiff" driver or am I 
doing something wrong?

Best Regards,
Adeel Raza.

More information about the gdal-dev mailing list