[GRASS-dev] [GRASS GIS] #3407: v.in.ogr fails to import ESRI Shapefile with empty attribute table cells

GRASS GIS trac at osgeo.org
Wed Aug 23 12:08:54 PDT 2017


#3407: v.in.ogr fails to import ESRI Shapefile with empty attribute table cells
----------------------+-------------------------
  Reporter:  mikatt   |      Owner:  grass-dev@…
      Type:  defect   |     Status:  new
  Priority:  normal   |  Milestone:
 Component:  Default  |    Version:  7.2.1
Resolution:           |   Keywords:
       CPU:  x86-64   |   Platform:  Linux
----------------------+-------------------------

Comment (by mmetz):

 Replying to [comment:6 rouault]:
 > > Regarding export from GRASS to OGR, what happens if a field is not
 explicitly set or unset? Is it now unset or set, but NULL? Do we need to
 adjust v.out.ogr using `OGR_F_SetFieldNull()` and/or `OGR_F_UnsetField()`
 instead of not touching the field at all?
 >
 > By default and by definition, a field that is not set ... is unset :-)
 This is no different in GDAL 2.2 than in previous versions. So depending
 on drivers, they might react differently on writing if a field is unset or
 if it set to an empty string. For CSV and Shapefile, this will result in
 the same file. For GeoJSON, a unset field doesn't appear at all in the
 result, whereas an empty string is written as '"field" : "" '

 Ok, a field that is not set is unset or set, but NULL, depending on the
 driver ;-)

 >
 > With GDAL 2.2, you can also set a field to NULL. The behaviour will
 depend on drivers. For CSV and Shapefile, NULL will be dealt as unset or
 empty string. For GeoJSON, it will be written as ' "field": null '.

 From [https://svn.osgeo.org/gdal/branches/2.2/gdal/MIGRATION_GUIDE.TXT]:

 "before, a unset field was written as field_name: null. Starting with GDAL
 2.2, only fields explicitly set as null with OGR_F_SetFieldNull() will be
 written with a null value."

 In order to preserve backwards compatibility for other software packages,
 GRASS will need to use OGR_F_SetFieldNull() starting with GDAL 2.2 if data
 export should not change.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3407#comment:7>
GRASS GIS <https://grass.osgeo.org>



More information about the grass-dev mailing list