Hi all<br><br>I have a strange problem when writing to a GDAL dataset. I'm currently doing the following:<br><br><div style="margin-left: 40px;"><i>GDALDataset *mInputDataset = (GDALDataset*) GDALOpen("in.tif", GA_ReadOnly);<br>
GDALDataType type = mInputDataset->GetRasterBand(1)->GetRasterDataType();<br>int mWidth = mInputDataset->GetRasterXSize();<br>int mHeight = mInputDataset->GetRasterYSize();<br><br>GDALDataset *mOutputDataset = mInputDataset->GetDriver()->Create("out.tif", mWidth, mHeight, mBands, type, 0);<br>
<br>int *data = <<get data for entire band>><br>mOutputDataset->GetRasterBand(1)->RasterIO(GF_Write, 0, 0, aligner.width(), aligner.height(), data, aligner.width(), aligner.height(), type, 0, 0);<br>mOutputDataset->FlushCache();<br>
</i></div><br>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.<br>
<br>Does anyone know why this is happening?<br>