<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;}
/* 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:#0563C1;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
span.E-mailStijl17
        {mso-style-type:personal-compose;
        font-family:"Calibri Light","sans-serif";
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";
        mso-fareast-language:EN-US;}
@page WordSection1
        {size:595.3pt 841.9pt;
        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 bgcolor="white" background="file:///C:\Program%20Files\Common%20Files\Microsoft%20Shared\Stationery\HandPrints.jpg" lang="NL" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri Light","sans-serif";mso-fareast-language:EN-US">Hi,<o:p></o:p></span></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">
http://www.qgis.org/api/classQgsVectorFileWriter.html#a1aac90d30d811d2888d1aab4098ad63c</a>. The symbology parameter seems tob e added in the latest release (QGis 2)<o:p></o:p></span></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"><span style="font-size:11.0pt;font-family:"Calibri Light","sans-serif";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";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";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";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";mso-fareast-language:EN-US">    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)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri Light","sans-serif";mso-fareast-language:EN-US">#    then import the shape file in a new layer<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri Light","sans-serif";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";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" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri Light","sans-serif";mso-fareast-language:EN-US">    QgsMapLayerRegistry.instance().addMapLayer(vlayer)</span><span style="font-size:11.0pt;font-family:"Calibri Light","sans-serif"">
<o:p></o:p></span></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.<o:p></o:p></span></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
<o:p></o:p></span></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,<o:p></o:p></span></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"><span style="font-size:11.0pt;font-family:"Calibri Light","sans-serif";mso-fareast-language:EN-US"><o:p> </o:p></span></p>
</div>
</body>
</html>