Opened 6 years ago

Closed 6 years ago

#30020 closed New feature (fixed)

Support reading null values for numeric fields on Shapefile import via LayerMapping

Reported by: Kathryn Killebrew Owned by: Kathryn Killebrew
Component: GIS Version:
Severity: Normal Keywords: GIS, GEOS, LayerMapping
Cc: claude@… Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

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

Change History (6)

comment:1 by Tim Graham, 6 years ago

Triage Stage: UnreviewedAccepted

comment:2 by Kathryn Killebrew, 6 years ago

Owner: changed from nobody to Kathryn Killebrew
Status: newassigned

comment:3 by Claude Paroz, 6 years ago

Cc: claude@… added

comment:4 by Tim Graham, 6 years ago

Has patch: set

comment:5 by Tim Graham, 6 years ago

Triage Stage: AcceptedReady for checkin

comment:6 by Tim Graham <timograham@…>, 6 years ago

Resolution: fixed
Status: assignedclosed

In 75d6278:

Fixed #30020 -- Fixed reading nulls with LayerMapping.

Note: See TracTickets for help on using tickets.
Back to Top