Hi all<br><br>I have a strange problem when writing to a GDAL dataset. I&#39;m currently doing the following:<br><br><div style="margin-left: 40px;"><i>GDALDataset *mInputDataset = (GDALDataset*) GDALOpen(&quot;in.tif&quot;, GA_ReadOnly);<br>
GDALDataType type = mInputDataset-&gt;GetRasterBand(1)-&gt;GetRasterDataType();<br>int mWidth = mInputDataset-&gt;GetRasterXSize();<br>int mHeight = mInputDataset-&gt;GetRasterYSize();<br><br>GDALDataset *mOutputDataset = mInputDataset-&gt;GetDriver()-&gt;Create(&quot;out.tif&quot;, mWidth, mHeight, mBands, type, 0);<br>
<br>int *data = &lt;&lt;get data for entire band&gt;&gt;<br>mOutputDataset-&gt;GetRasterBand(1)-&gt;RasterIO(GF_Write, 0, 0, aligner.width(), aligner.height(), data, aligner.width(), aligner.height(), type, 0, 0);<br>mOutputDataset-&gt;FlushCache();<br>
</i></div><br>The input image provided has a datatype of UINT16. When I hardcode all &quot;type&quot; 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 &quot;type&quot;), 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&#39;ve checked the data array, and all the values in there are correct.<br>
<br>Does anyone know why this is happening?<br>