[gdal-dev] Writing raster - 0 in every even column

Goo Creations goocreations at gmail.com
Fri Jun 3 06:13:41 EDT 2011


Hi all

I have a strange problem when writing to a GDAL dataset. I'm currently doing
the following:

*GDALDataset *mInputDataset = (GDALDataset*) GDALOpen("in.tif",
GA_ReadOnly);
GDALDataType type = mInputDataset->GetRasterBand(1)->GetRasterDataType();
int mWidth = mInputDataset->GetRasterXSize();
int mHeight = mInputDataset->GetRasterYSize();

GDALDataset *mOutputDataset = mInputDataset->GetDriver()->Create("out.tif",
mWidth, mHeight, mBands, type, 0);

int *data = <<get data for entire band>>
mOutputDataset->GetRasterBand(1)->RasterIO(GF_Write, 0, 0, aligner.width(),
aligner.height(), data, aligner.width(), aligner.height(), type, 0, 0);
mOutputDataset->FlushCache();
*

The input image provided has a datatype of UINT16. When I hardcode all
"type" variables in the above example to GDT_Int32, then the image is
correctly created, but when I leave the example as is (hence with GDT_UInt16
assigned to "type"), then I get a strange problem that every second column
has a value of 0. So every odd column has the correct values in, but every
even column has values of 0. I've checked the data array, and all the values
in there are correct.

Does anyone know why this is happening?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/gdal-dev/attachments/20110603/b0627a9e/attachment-0001.html


More information about the gdal-dev mailing list