[Django] #37055: GDALRaster fails when using Float and NBITS=16

21 views
Skip to first unread message

Django

unread,
Apr 21, 2026, 12:29:50 PMApr 21
to django-...@googlegroups.com
#37055: GDALRaster fails when using Float and NBITS=16
-------------------------------------+-------------------------------------
Reporter: Marcos Sánchez | Type: Bug
Provencio |
Status: new | Component: GIS
Version: 5.2 | Severity: Normal
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
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
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/37055>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Apr 21, 2026, 12:36:24 PMApr 21
to django-...@googlegroups.com
#37055: GDALRaster fails when using Float and NBITS=16
-------------------------------------+-------------------------------------
Reporter: Marcos Sánchez | Owner: (none)
Provencio |
Type: Bug | Status: new
Component: GIS | Version: 5.2
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Marcos Sánchez Provencio):

GDAL version might be relevant. I was using this in Ubuntu 24.04 without
problems.
Working (ubuntu 24.04):
{{{
gdalinfo --version
GDAL 3.8.4, released 2024/02/08
}}}

Not working (ubuntu 26.04)
{{{
gdalinfo --version
GDAL 3.12.2 "Chicoutimi", released 2026/02/03
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/37055#comment:1>

Django

unread,
Apr 24, 2026, 4:17:46 PMApr 24
to django-...@googlegroups.com
#37055: GDALRaster fails when using Float and NBITS=16
-------------------------------------+-------------------------------------
Reporter: Marcos Sánchez | Owner: (none)
Provencio |
Type: New feature | Status: new
Component: GIS | Version: 6.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by David Smith):

* stage: Unreviewed => Accepted
* type: Bug => New feature
* version: 5.2 => 6.0

Comment:

GDAL 3.11 added support for float16, see
[https://gdal.org/en/stable/development/rfc/rfc100_float16_support.html
RFC].

This
[https://github.com/django/django/commit/7af455a402bf383575a494243e766d6247fd86a3
PR] added some interger types. It could be used for inspiration for a PR
to resolve this ticket.
--
Ticket URL: <https://code.djangoproject.com/ticket/37055#comment:2>

Django

unread,
May 1, 2026, 10:29:22 AMMay 1
to django-...@googlegroups.com
#37055: GDALRaster fails when using Float and NBITS=16
-------------------------------------+-------------------------------------
Reporter: Marcos Sánchez | Owner: Rish
Provencio |
Type: New feature | Status: assigned
Component: GIS | Version: 6.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Rish):

* owner: (none) => Rish
* status: new => assigned

--
Ticket URL: <https://code.djangoproject.com/ticket/37055#comment:3>

Django

unread,
May 3, 2026, 4:11:22 PMMay 3
to django-...@googlegroups.com
#37055: GDALRaster fails when using Float and NBITS=16
-------------------------------------+-------------------------------------
Reporter: Marcos Sánchez | Owner: Rish
Provencio |
Type: New feature | Status: assigned
Component: GIS | Version: 6.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Rish):

Note: Currently there is a [DDoS
attack](https://askubuntu.com/questions/1566282/ubuntu-infrastructure-
including-ppa-launchpadcontent-net-not-responding-returni) on Ubuntu going
on, due to which I wasn't able to access ppa repo, for the latest 3.11
GDAL. Thankfully, there are
[images](https://github.com/osgeo/gdal/pkgs/container/gdal/513073460?tag
=ubuntu-full-3.11.4) available for this, on which I am working.
--
Ticket URL: <https://code.djangoproject.com/ticket/37055#comment:4>

Django

unread,
May 10, 2026, 4:06:01 PMMay 10
to django-...@googlegroups.com
#37055: GDALRaster fails when using Float and NBITS=16
-------------------------------------+-------------------------------------
Reporter: Marcos Sánchez | Owner: Rish
Provencio |
Type: New feature | Status: assigned
Component: GIS | Version: 6.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Rish):

* has_patch: 0 => 1

--
Ticket URL: <https://code.djangoproject.com/ticket/37055#comment:5>

Django

unread,
May 11, 2026, 3:06:17 PMMay 11
to django-...@googlegroups.com
#37055: GDALRaster fails when using Float and NBITS=16
-------------------------------------+-------------------------------------
Reporter: Marcos Sánchez | Owner: Rish
Provencio |
Type: New feature | Status: assigned
Component: GIS | Version: 6.0
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by David Smith):

* needs_better_patch: 0 => 1
* needs_tests: 0 => 1

--
Ticket URL: <https://code.djangoproject.com/ticket/37055#comment:6>
Reply all
Reply to author
Forward
0 new messages