[Qgis-developer] SymbologyExport parameter

Pim Verver pim at travelingo.nl
Sat Dec 28 06:25:27 PST 2013

I am using the QGis python console for the use of exporting an active layer from postgist to a shape file layer.  I want to include the symbology as is possible through the GUI of QGis 2 (Dufour).
I am using the writeAsVectorFormat<http://www.qgis.org/api/classQgsVectorFileWriter.html#a289af78b5b609fbcb0572aaf505f2822> method of the QgsVectorFileWriter class, but keep getting the message that there are "Too many arguments" as if the parameter doesn´t exist. That seems correct given the fact that the mouse popup for the parameters doesn't indicate a Symbology parameter. However in the  official QGis API the parameter is mentioned: http://www.qgis.org/api/classQgsVectorFileWriter.html#a1aac90d30d811d2888d1aab4098ad63c. The symbology parameter seems tob e added in the latest release (QGis 2)
Am I using it the wrong way or is someting else going on?
The alternative would be save the style als SLD and import the style file after creating the shape layer, but if I can avoid that ...
The console code sofar:
canvas = iface.mapCanvas()
aLayer = iface.activeLayer()
if aLayer.dataProvider().name() == 'postgres':
    writer =  QgsVectorFileWriter
    error = writer.writeAsVectorFormat(aLayer, r"D:\Documenten_Travelingo\SkyDrive Pro\Horeca routes\Projectbestanden\deBaak Driebergen\Shape bronnen\\"+ aLayer.name() + ".shp", "CP1250", None, "ESRI Shapefile", False, None,"","", False, None, "NoSymbology", 1.0)
#    then import the shape file in a new layer
if error == QgsVectorFileWriter.NoError:
    vlayer = QgsVectorLayer(r"D:\Documenten_Travelingo\SkyDrive Pro\Horeca routes\Projectbestanden\deBaak Driebergen\Shape bronnen", aLayer.name() + ".shp", "ogr")
Th error is raised at the writeAsVectorFormat method and its parameter NoSymbology.
Thanx in advance
Kinds regards,
Pim Verver

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20131228/e0e99b77/attachment.html>

More information about the Qgis-developer mailing list