[QGIS-trac] [Quantum GIS] #2151: "Save as shapefile..." truncates field names, sometimes causing duplicates

Quantum GIS qgis at qgis.org
Wed Nov 25 12:04:26 EST 2009


#2151: "Save as shapefile..." truncates field names, sometimes causing duplicates
------------------------------------------------+---------------------------
   Reporter:  dmorissette                       |              Owner:  nobody       
       Type:  bug                               |             Status:  new          
   Priority:  major: does not work as expected  |          Milestone:  Version 1.4.0
  Component:  Vectors                           |            Version:  HEAD         
   Keywords:                                    |   Platform_version:               
   Platform:  Debian                            |           Must_fix:  No           
Status_info:  0                                 |  
------------------------------------------------+---------------------------
 Since the DBF format limits field/attribute names to 10 chars, the "Save
 as shapefile" command (from the right-click menu on vector layers in
 legend) has to truncate the name of fields longer than 10 chars. However,
 this is done without checking for potential duplicates field names.

 For instance, if a dataset contains fields "mylongattr1" and
 "mylongattr2", they are both written as "mylongattr". We should change the
 dups to have a unique name, presumably by adding a unique number at the
 end.

 I believe QGIS uses OGR for this export (am I right?). If that's the case
 then the source of the problem is in the OGR shapefile driver where the
 field name truncation happens. I have filed an OGR ticket about this with
 a testcase to reproduce, and once it's fixed QGIS should automagically
 benefit from the fix:
   http://trac.osgeo.org/gdal/ticket/3247

 However, QGIS could possibly have some smarts to better handle this in the
 meantime. I'll let you decide if you wait for OGR or implement a fix in
 QGIS.

-- 
Ticket URL: <http://trac.osgeo.org/qgis/ticket/2151>
Quantum GIS <http://qgis.org>
Quantum GIS is an Open Source GIS viewer/editor supporting OGR, PostGIS, and GRASS formats


More information about the QGIS-trac mailing list