[gdal-dev] AutoCreateWarpedVRT changes Int16 raster to Int32

Denis Rykov rykovd at gmail.com
Sat Aug 31 15:17:55 PDT 2024


Issue Report Rephrased:

For certain rasters with an *Int16* data type, calling AutoCreateWarpedVRT
changes the dataset type to *Int32*. For example:

>>> ds1 = gdal.Open("dem.tif", gdalconst.GA_ReadOnly)
>>> ds1.GetRasterBand(1).DataType
3
>>> ds2 = gdal.AutoCreateWarpedVRT(ds1)
>>> ds2.GetRasterBand(1).DataType
5
>>> ds2.GetRasterBand(1).GetNoDataValue()
32767.0

However, when I tested it on another raster, the type did not change:

>>> ds1 = gdal.Open("int16_50m.tif", gdalconst.GA_ReadOnly)
>>> ds1.GetRasterBand(1).DataType
3
>>> ds2 = gdal.AutoCreateWarpedVRT(ds1)
>>> ds2.GetRasterBand(1).DataType
3
>>> ds2.GetRasterBand(1).GetNoDataValue()
-32768.0

Is this a bug? It appears that the data type change might be influenced by
the nodata value.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20240901/1c13ab2c/attachment.htm>


More information about the gdal-dev mailing list