Uploaded image for project: 'GeoTools'
  1. GeoTools
  2. GEOT-5617

Shapefile attribute (DBF) DbaseFileReader reads numeric empty values as zero

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Medium
    • Resolution: Fixed
    • Affects Version/s: 16.1
    • Fix Version/s: 16.3
    • Component/s: shapefile plugin
    • Labels:
      None
    • Environment:

      all

      Description

      Dealing with null values in shapefile attributes (DBF files) is tricky. It is not very well defined. Also see GEOT-3204 Closed

      QGis and OGR2OGR write out stars (*****) for null values. However, many other tools will put spaces (hex 20).

      The current DbaseFileReader will parse spaces as 0.0 (zero). Which makes it impossible to distinguish the null value from a real zero value. See lines 581-583:
      https://github.com/geotools/geotools/blob/master/modules/plugin/shapefile/src/main/java/org/geotools/data/shapefile/dbf/DbaseFileReader.java#L581

      I believe a better solution would be to return unparsable data as null instead of a rather arbitrary zero. That or throw an exception.

      Attached is a simple test case with 4 different records. One contains a value, another zero, another stars and the final one contains spaces.

      I can submit a pull request to fix this if this is accepted.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              pbackx Peter Backx
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: