[QGIS-trac] [Quantum GIS] #3148: ftools,
buffering: error in shapefile writing
Quantum GIS
qgis at qgis.org
Fri Oct 22 08:32:04 EDT 2010
#3148: ftools, buffering: error in shapefile writing
---------------------------------------------------------+------------------
Reporter: elpaso | Owner: borysiasty
Type: bug | Status: new
Priority: critical: causes crash or data corruption | Milestone: Version 1.6.0
Component: Python plugins and bindings | Version:
Keywords: ftools, shapefile, buffering | Platform_version:
Platform: Debian | Must_fix: No
Status_info: 0 |
---------------------------------------------------------+------------------
this is a more general issue, because QGIS fails to save shapefiles when
there are conflicts in field names after DBF 8 char truncation.
The perfect solution would be an automated conflict resolving systen when
truncating field names, but I did not (yet) indagate how shapefiles are
written (OGR or what?).
A quick and dirty hack to solve the ftool->geoprocessing->buffer issue,
consists in considering only the first field when creating the shapefile:
diff tmp/ftool.mod
/usr/share/qgis/python/plugins/fTools/tools/doGeoprocessing.py
297,298d296
< # ABP:
< fields = { 0 : fields[0] }
Full story:
I'm preparing a QGIS demo for tomorrow's italian Linux Day meeting and I'm
hitting an error with Ftools->buffering.
Basically, I'm building a 20 m buffer around a selected linestring (first
I select one geometry from a postgis vector layer, but I get the same
result if the selected geometry comes from a sqlite file), I'm saving the
buffer in /home/me/tmp/buf.shp, the plugin says :
Shapefile in ouput creato:
/home/me/tmp/buf.shp
but the file is not there (and this is a bug: the message shouldn't say
the the file has been created when it is not), adding to the legend throws
an error since the file does not exists and cannot be loaded.
The problem originates from QGIS shapefile writer which cannot resolve
conflicts between field names (which are truncated at 8 chars or so
AFAIK).
I soved hacking the ftools plugin code
$ diff tmp/ftool.mod
/usr/share/qgis/python/plugins/fTools/tools/doGeoprocessing.py
297,298d296
< # ABP:
< fields = { 0 : fields[0] }
a couple of thoughts:
1 - fTools (or QgsVectorFileWriter ?) should better handle errors when
shapefile conversion - save fails
2 - an option to save buffer and other results to temporary in-memory
layer should be provided
3 - is it really necessary to copy all source vector fields in the result
file ? Not in the buffer function, maybe in the other tools ?
4 - the docs say QgsFileWriter will support other output formats, is there
a roadmap for this feature ? This could eventually solve many conversion
errors due to shapefile (DBF) limitations
5 - it's not clear to me how to catch QgsFileWriter errors from python
code while delegating real writing to the destructor (see: "del writer" in
the plugin's code), this could solve point 1 in this
--
Ticket URL: <https://trac.osgeo.org/qgis/ticket/3148>
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