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 , 6 years ago
Triage Stage: | Unreviewed → Accepted |
---|
comment:2 by , 6 years ago
Owner: | changed from | to
---|---|
Status: | new → assigned |
comment:3 by , 6 years ago
Cc: | added |
---|
comment:4 by , 6 years ago
Has patch: | set |
---|
comment:5 by , 6 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
PR