[Django] #36196: django.contrib.gis.GDALRaster support for driver configuration options

8 views
Skip to first unread message

Django

unread,
Feb 17, 2025, 4:17:36 AMFeb 17
to django-...@googlegroups.com
#36196: django.contrib.gis.GDALRaster support for driver configuration options
--------------------------------+---------------------------------------
Reporter: Jordi Castells | Type: New feature
Status: new | Component: GIS
Version: 5.1 | 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
--------------------------------+---------------------------------------
Some raster files will refuse to open when using newer versions of GDAL
(for example 3.8).

GDAL behaves as expected, although it is not always as desired. It brought
to my attention that there is no support for driver specific open options
when calling `contrib.gis.GDALRaster`

There is driver option support via `papsz_options` when creating
GDALRaster from scratch
(https://docs.djangoproject.com/en/5.1/ref/contrib/gis/gdal/#creating-
rasters-from-data) but not when opening an existing raster file
(https://docs.djangoproject.com/en/5.1/ref/contrib/gis/gdal/#gdalraster).

The example that I can come up now is opening a `COG` directly with
`contrib.gis.GDALRaster` and requiring the option
`IGNORE_COG_LAYOUT_BREAK`, but I imagine that other drivers would benefit
from this capability.
--
Ticket URL: <https://code.djangoproject.com/ticket/36196>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Feb 17, 2025, 7:51:33 AMFeb 17
to django-...@googlegroups.com
#36196: django.contrib.gis.GDALRaster support for driver configuration options
--------------------------------+--------------------------------------
Reporter: Jordi Castells | Owner: (none)
Type: New feature | Status: new
Component: GIS | Version: 5.1
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
--------------------------------+--------------------------------------
Description changed by Jordi Castells:

Old description:

> Some raster files will refuse to open when using newer versions of GDAL
> (for example 3.8).
>
> GDAL behaves as expected, although it is not always as desired. It
> brought to my attention that there is no support for driver specific open
> options when calling `contrib.gis.GDALRaster`
>
> There is driver option support via `papsz_options` when creating
> GDALRaster from scratch
> (https://docs.djangoproject.com/en/5.1/ref/contrib/gis/gdal/#creating-
> rasters-from-data) but not when opening an existing raster file
> (https://docs.djangoproject.com/en/5.1/ref/contrib/gis/gdal/#gdalraster).
>
> The example that I can come up now is opening a `COG` directly with
> `contrib.gis.GDALRaster` and requiring the option
> `IGNORE_COG_LAYOUT_BREAK`, but I imagine that other drivers would benefit
> from this capability.

New description:

Some raster files will refuse to open when using newer versions of GDAL
(for example 3.8).

GDAL behaves as expected, although it is not always as desired. It brought
to my attention that there is no support for driver specific open options
when calling `contrib.gis.GDALRaster`

There is driver option support via `papsz_options` when creating
GDALRaster from scratch
(https://docs.djangoproject.com/en/5.1/ref/contrib/gis/gdal/#creating-
rasters-from-data) but not when opening an existing raster file
(https://docs.djangoproject.com/en/5.1/ref/contrib/gis/gdal/#gdalraster).

The example that I can come up now is opening a `COG` directly with
`contrib.gis.GDALRaster` and requiring the option
`IGNORE_COG_LAYOUT_BREAK`, but I imagine that other drivers would benefit
from this capability.

.. note: I can prepare this patch myself but first I would like opinion
from the maintainers :-)

--
--
Ticket URL: <https://code.djangoproject.com/ticket/36196#comment:1>

Django

unread,
Feb 18, 2025, 8:38:43 AMFeb 18
to django-...@googlegroups.com
#36196: django.contrib.gis.GDALRaster support for driver configuration options
--------------------------------+------------------------------------
Reporter: Jordi Castells | Owner: (none)
Type: New feature | Status: new
Component: GIS | Version: 5.1
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 Sarah Boyce):

* cc: Daniel Wiesmann, Mariusz Felisiak (added)
* stage: Unreviewed => Accepted

Comment:

This sounds reasonable to me and so tentatively accepting
I don't have much experience in this space and so cc-ing some folks in
case they have opinions
--
Ticket URL: <https://code.djangoproject.com/ticket/36196#comment:2>

Django

unread,
Feb 19, 2025, 7:10:45 AMFeb 19
to django-...@googlegroups.com
#36196: django.contrib.gis.GDALRaster support for driver configuration options
--------------------------------+------------------------------------------
Reporter: Jordi Castells | Owner: Jordi Castells
Type: New feature | Status: assigned
Component: GIS | Version: 5.1
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 Jacob Walls):

* owner: (none) => Jordi Castells
* status: new => assigned

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

Django

unread,
Feb 21, 2025, 4:06:15 AMFeb 21
to django-...@googlegroups.com
#36196: django.contrib.gis.GDALRaster support for driver configuration options
--------------------------------+------------------------------------------
Reporter: Jordi Castells | Owner: Jordi Castells
Type: New feature | Status: assigned
Component: GIS | Version: 5.1
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 Jordi Castells):

I see some possible inconsistencies rising from this:

`GDALRaster(ds_input, mode)`

My first instinct was to extend this to be more akin to a `GDAL OpenEx` ->
`GdalRaster(ds_input, mode, papsz_open_options=None)`

But, `ds_input` can be one of the following
* `string` -> Assume apath
* `bytes` -> Assume in memory raster
* `dict` -> Definition to create a raster from scratch

We already have possibility to pass `papsz_options` to the `ds_input` when
it is a `dict`.

So that would clash with my original intent.

I think what makes more sense is to remove that
`dict["papsz_open_options"]` and all calls to `GDALRaster` could use the
different open options available. Open an existing raster file could
provide extra open options, and creating a raster from scratch could
provide the current dict + pass some extra information via the optional
parameter. Although that would mean breaking the current use of `creating
a new raster`.

We could also go with the two options (`dict["papsz_*"]` and optional
`papsz_*` parameter) but that could make creating rasters from scratch
more confusing since there are two places where to define `papsz` and only
one right one.
--
Ticket URL: <https://code.djangoproject.com/ticket/36196#comment:4>
Reply all
Reply to author
Forward
0 new messages