﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
37055	GDALRaster fails when using Float and NBITS=16	Marcos Sánchez Provencio		"GDALRaster creation fails when trying to use NBITS=16 (thus creating a Float16 dataset)
{{{
In [39]: >>> import tempfile
rstfile = tempfile.NamedTemporaryFile(suffix="".tif"")
rst = GDALRaster(
    {
         ""driver"": ""GTiff"",
         ""name"": rstfile.name,
         ""srid"": 4326,
          ""width"": 255,
          ""height"": 255,
          ""nr_of_bands"": 1,
              ""papsz_options"":dict(NBITS=32)
      }
  )

In [40]: rst.bands[0].data()
Out[40]: 
array([[0., 0., 0., ..., 0., 0., 0.],
       [0., 0., 0., ..., 0., 0., 0.],
       [0., 0., 0., ..., 0., 0., 0.],
       ...,
       [0., 0., 0., ..., 0., 0., 0.],
       [0., 0., 0., ..., 0., 0., 0.],
       [0., 0., 0., ..., 0., 0., 0.]], dtype=float32)

}}}
But this fails:
{{{

In [42]: rst.bands[0].data()
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
Cell In[42], line 1
----> 1 rst.bands[0].data()

File ~/v_django4/lib/python3.14/site-packages/django/contrib/gis/gdal/raster/band.py:207, in GDALBand.data(self, data, offset, size, shape, as_memoryview)
    204     raise ValueError(""Size is larger than raster."")
    206 # Create ctypes type array generator
--> 207 ctypes_array = GDAL_TO_CTYPES[self.datatype()] * (shape[0] * shape[1])
    209 if data is None:
    210     # Set read mode
    211     access_flag = 0

IndexError: list index out of range
}}}"	Bug	new	GIS	5.2	Normal			Marcos Sánchez Provencio	Unreviewed	0	0	0	0	0	0
