[Django] #30020: Support reading null values for numeric fields on Shapefile import via LayerMapping

8 views
Skip to first unread message

Django

unread,
Dec 7, 2018, 4:28:03 PM12/7/18
to django-...@googlegroups.com
#30020: Support reading null values for numeric fields on Shapefile import via
LayerMapping
-------------------------------------+-------------------------------------
Reporter: Kathryn | Owner: nobody
Killebrew |
Type: New | Status: new
feature |
Component: GIS | Version:
Severity: Normal | Keywords: GIS, GEOS,
Triage Stage: | LayerMapping
Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
On reading a Shapefile into a model object via `LayerMapping`, set numeric
field value to `None` instead of zero if the model field is nullable and
input field value is either null or unset. Currently, both nulls and
zeroes in the input are stored as zeroes.

Shapefiles do not officially support storing nulls:
http://resources.esri.com/help/9.3/ArcGISDesktop/com/Gp_ToolRef/geoprocessing_tool_reference/geoprocessing_considerations_for_shapefile_output.htm

However, on inspecting the DBF contents via `ogrinfo` with GDAL 2.1 or
2.2, both zeroes and nulls display, so some unofficial support exists.

GDAL 2.2 added support for distinguishing between "unset" fields and those
explicitly set to null:
https://trac.osgeo.org/gdal/wiki/rfc67_nullfieldvalues

Adding null support should be possible by either checking before casting
the value with OGR `IsFieldSetAndNotNull` on GDAL 2.2+ or checking with
OGR `IsFieldSet` on older GDAL versions:
https://www.gdal.org/classOGRFeature.html#a260b925400b72914eb1b8cc9a3bf4029

--
Ticket URL: <https://code.djangoproject.com/ticket/30020>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Dec 7, 2018, 5:56:53 PM12/7/18
to django-...@googlegroups.com
#30020: Support reading null values for numeric fields on Shapefile import via
LayerMapping
-------------------------------------+-------------------------------------
Reporter: Kathryn Killebrew | Owner: nobody
Type: New feature | Status: new
Component: GIS | Version:
Severity: Normal | Resolution:
Keywords: GIS, GEOS, | Triage Stage: Accepted
LayerMapping |

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* stage: Unreviewed => Accepted


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

Django

unread,
Dec 13, 2018, 1:25:28 AM12/13/18
to django-...@googlegroups.com
#30020: Support reading null values for numeric fields on Shapefile import via
LayerMapping
-------------------------------------+-------------------------------------
Reporter: Kathryn Killebrew | Owner: Kathryn
| Killebrew
Type: New feature | Status: assigned
Component: GIS | Version:
Severity: Normal | Resolution:
Keywords: GIS, GEOS, | Triage Stage: Accepted
LayerMapping |

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Kathryn Killebrew):

* owner: nobody => Kathryn Killebrew
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/30020#comment:2>

Django

unread,
Dec 13, 2018, 3:04:53 AM12/13/18
to django-...@googlegroups.com
#30020: Support reading null values for numeric fields on Shapefile import via
LayerMapping
-------------------------------------+-------------------------------------
Reporter: Kathryn Killebrew | Owner: Kathryn
| Killebrew
Type: New feature | Status: assigned
Component: GIS | Version:
Severity: Normal | Resolution:
Keywords: GIS, GEOS, | Triage Stage: Accepted
LayerMapping |

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Claude Paroz):

* cc: claude@… (added)


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

Django

unread,
Dec 24, 2018, 11:41:23 AM12/24/18
to django-...@googlegroups.com
#30020: Support reading null values for numeric fields on Shapefile import via
LayerMapping
-------------------------------------+-------------------------------------
Reporter: Kathryn Killebrew | Owner: Kathryn
| Killebrew
Type: New feature | Status: assigned
Component: GIS | Version:
Severity: Normal | Resolution:
Keywords: GIS, GEOS, | Triage Stage: Accepted
LayerMapping |
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* has_patch: 0 => 1


Comment:

[https://github.com/django/django/pull/10760 PR]

--
Ticket URL: <https://code.djangoproject.com/ticket/30020#comment:4>

Django

unread,
Jan 30, 2019, 6:23:10 PM1/30/19
to django-...@googlegroups.com
#30020: Support reading null values for numeric fields on Shapefile import via
LayerMapping
-------------------------------------+-------------------------------------
Reporter: Kathryn Killebrew | Owner: Kathryn
| Killebrew
Type: New feature | Status: assigned
Component: GIS | Version:
Severity: Normal | Resolution:
Keywords: GIS, GEOS, | Triage Stage: Ready for
LayerMapping | checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham):

* stage: Accepted => Ready for checkin


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

Django

unread,
Jan 31, 2019, 7:51:00 PM1/31/19
to django-...@googlegroups.com
#30020: Support reading null values for numeric fields on Shapefile import via
LayerMapping
-------------------------------------+-------------------------------------
Reporter: Kathryn Killebrew | Owner: Kathryn
| Killebrew
Type: New feature | Status: closed
Component: GIS | Version:
Severity: Normal | Resolution: fixed

Keywords: GIS, GEOS, | Triage Stage: Ready for
LayerMapping | checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"75d627888bf42f8de6064a0bd665c98c0df66c55" 75d6278]:
{{{
#!CommitTicketReference repository=""
revision="75d627888bf42f8de6064a0bd665c98c0df66c55"
Fixed #30020 -- Fixed reading nulls with LayerMapping.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/30020#comment:6>

Reply all
Reply to author
Forward
0 new messages