<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:"Calibri Light";
        panose-1:2 15 3 2 2 2 4 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.E-mailStijl17
        {mso-style-type:personal-reply;
        font-family:"Calibri Light","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";
        mso-fareast-language:EN-US;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:70.85pt 70.85pt 70.85pt 70.85pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="NL" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri Light","sans-serif";color:#1F497D;mso-fareast-language:EN-US">Hi Tim,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri Light","sans-serif";color:#1F497D;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri Light","sans-serif";color:#1F497D;mso-fareast-language:EN-US">I executed an exact copy of your line of code and got the same error’<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri Light","sans-serif";color:#1F497D;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri Light","sans-serif";color:#1F497D;mso-fareast-language:EN-US">This is what I tried:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri Light","sans-serif";color:#1F497D;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri Light","sans-serif";color:#1F497D;mso-fareast-language:EN-US">canvas = iface.mapCanvas()<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri Light","sans-serif";color:#1F497D;mso-fareast-language:EN-US">aLayer = iface.activeLayer()<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri Light","sans-serif";color:#1F497D;mso-fareast-language:EN-US">if aLayer.dataProvider().name() == 'postgres':<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri Light","sans-serif";color:#1F497D;mso-fareast-language:EN-US">    writer =  QgsVectorFileWriter<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri Light","sans-serif";color:#1F497D;mso-fareast-language:EN-US">    error = writer.writeAsVectorFormat(aLayer, r"/tmp/out.shp", "CP1250", None, "ESRI Shapefile", False, None,"","", False,
 None, QgsVectorFileWriter.NoSymbology, 1.0)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri Light","sans-serif";color:#1F497D;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri Light","sans-serif";color:#1F497D;mso-fareast-language:EN-US">if error == QgsVectorFileWriter.NoError:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri Light","sans-serif";color:#1F497D;mso-fareast-language:EN-US">    vlayer = QgsVectorLayer(r"D:\Documenten_Travelingo\SkyDrive Pro\Horeca routes\Projectbestanden\deBaak Driebergen\Shape
 bronnen", aLayer.name() + ".shp", "ogr")<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri Light","sans-serif";color:#1F497D;mso-fareast-language:EN-US">    QgsMapLayerRegistry.instance().addMapLayer(vlayer)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri Light","sans-serif";color:#1F497D;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri Light","sans-serif";color:#1F497D;mso-fareast-language:EN-US">And the error: Tceback (most recent call last):<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri Light","sans-serif";color:#1F497D;mso-fareast-language:EN-US">  File "<input>", line 1, in <module><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri Light","sans-serif";color:#1F497D;mso-fareast-language:EN-US">  File "D:/Documenten_Travelingo/SkyDrive Pro/Horeca routes/PostgrestoShape.py", line 5, in <module><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri Light","sans-serif";color:#1F497D;mso-fareast-language:EN-US">    error = writer.writeAsVectorFormat(aLayer, r"/tmp/out.shp", "CP1250", None, "ESRI Shapefile", False, None,"","", False,
 None, QgsVectorFileWriter.NoSymbology, 1.0)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri Light","sans-serif";color:#1F497D;mso-fareast-language:EN-US">AttributeError: type object 'QgsVectorFileWriter' has no attribute 'NoSymbology'<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri Light","sans-serif";color:#1F497D;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri Light","sans-serif";color:#1F497D;mso-fareast-language:EN-US">I work with the console of  a Dufour 64 bits version on a Windows 8.1 machine. The qgis_core.dll is present in C:\Program Files\QGIS
 Dufour\apps\qgis\bin. Can it be that the windows version is an old compilation because as I understand the SymbologyExport parameter was just recently added to the source code?<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri Light","sans-serif";color:#1F497D;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri Light","sans-serif";color:#1F497D;mso-fareast-language:EN-US">Kind regards<o:p></o:p></span></p>
<p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:"Calibri","sans-serif"">Van:</span></b><span style="font-size:11.0pt;font-family:"Calibri","sans-serif""> Tim Sutton [mailto:lists@linfiniti.com]
<br>
<b>Verzonden:</b> zaterdag 28 december 2013 22:19<br>
<b>Aan:</b> Pim Verver<br>
<b>CC:</b> qgis-developer@lists.osgeo.org<br>
<b>Onderwerp:</b> Re: [Qgis-developer] SymbologyExport parameter<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal">Hi<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">I'm not sure why the Symbology flag is not working (havent time to look sorry) but a quick fix might be to do this (which worked for me in a quick test):<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<div>
<p class="MsoNormal">error = writer.writeAsVectorFormat(aLayer, r"/tmp/out.shp", "CP1250", None, "ESRI Shapefile", False, None,"","", False, None, QgsVectorFileWriter.NoSymbology, 1.0)<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">aLayer.saveNamedStyle("/tmp/out.qml")<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">(u'Created default style file as /tmp/out.qml', True)<o:p></o:p></p>
</div>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Hope that helps!<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Regards<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Tim<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><o:p> </o:p></p>
<div>
<p class="MsoNormal">On Sat, Dec 28, 2013 at 4:25 PM, Pim Verver <<a href="mailto:pim@travelingo.nl" target="_blank">pim@travelingo.nl</a>> wrote:<o:p></o:p></p>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm">
<div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri Light","sans-serif"">Hi,</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri Light","sans-serif"">I am using the QGis python console for the use of exporting an active layer from postgist to a shape file
 layer. <i> </i>I want to include the symbology as is possible through the GUI of QGis 2 (Dufour).<br>
I am using the <a href="http://www.qgis.org/api/classQgsVectorFileWriter.html#a289af78b5b609fbcb0572aaf505f2822" target="_blank">
<span style="color:windowtext;text-decoration:none">writeAsVectorFormat</span></a> 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:
<a href="http://www.qgis.org/api/classQgsVectorFileWriter.html#a1aac90d30d811d2888d1aab4098ad63c" target="_blank">
http://www.qgis.org/api/classQgsVectorFileWriter.html#a1aac90d30d811d2888d1aab4098ad63c</a>. The symbology parameter seems tob e added in the latest release (QGis 2)</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri Light","sans-serif"">Am I using it the wrong way or is someting else going on?</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri Light","sans-serif"">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 …</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri Light","sans-serif"">The console code sofar:</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri Light","sans-serif"">canvas = iface.mapCanvas()</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri Light","sans-serif"">aLayer = iface.activeLayer()</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri Light","sans-serif"">if aLayer.dataProvider().name() == 'postgres':</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri Light","sans-serif"">    writer =  QgsVectorFileWriter</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri Light","sans-serif"">    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)</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri Light","sans-serif"">#    then import the shape file in a new layer</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri Light","sans-serif"">if error == QgsVectorFileWriter.NoError:</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri Light","sans-serif"">    vlayer = QgsVectorLayer(r"D:\Documenten_Travelingo\SkyDrive Pro\Horeca routes\Projectbestanden\deBaak
 Driebergen\Shape bronnen", aLayer.name() + ".shp", "ogr")</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri Light","sans-serif"">    QgsMapLayerRegistry.instance().addMapLayer(vlayer)
</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri Light","sans-serif"">Th error is raised at the writeAsVectorFormat method and its parameter NoSymbology.</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri Light","sans-serif"">Thanx in advance
</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri Light","sans-serif"">Kinds regards,</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri Light","sans-serif"">Pim Verver</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri Light","sans-serif""> </span><o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><br>
_______________________________________________<br>
Qgis-developer mailing list<br>
<a href="mailto:Qgis-developer@lists.osgeo.org">Qgis-developer@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/qgis-developer" target="_blank">http://lists.osgeo.org/mailman/listinfo/qgis-developer</a><o:p></o:p></p>
</blockquote>
</div>
<p class="MsoNormal"><br>
<br clear="all">
<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<p class="MsoNormal">-- <o:p></o:p></p>
<div>
<p class="MsoNormal">Tim Sutton - QGIS Project Steering Committee Member<br>
==============================================<br>
Please do not email me off-list with technical<br>
support questions. Using the lists will gain<br>
more exposure for your issues and the knowledge<br>
surrounding your issue will be shared with all.<br>
<br>
Irc: timlinux on #qgis at <a href="http://freenode.net" target="_blank">freenode.net</a><br>
==============================================<o:p></o:p></p>
</div>
</div>
</div>
</body>
</html>