<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<p>Hi Marian,</p>
<p>I suppose the QGIS Clip algorithm does not work on
"memory"-Layers, i.e. Layers that are not written to disk. You can
either try to save your layer as a shapefile and then run the
clipping algorithm, or iterate over the geometries and use the
QgsGeometry.Intersection(QgsGeometry) function
(<a class="moz-txt-link-freetext" href="https://qgis.org/api/classQgsGeometry.html#a6ca0f918c7c67aff8ac9e0094707c99e">https://qgis.org/api/classQgsGeometry.html#a6ca0f918c7c67aff8ac9e0094707c99e</a>).</p>
<p>This could be something like this (not tested, just off the top
of my head):<br>
clipPoly = clipLayer.getFeatures()[0].geometry() # get the first
feature (assumes only one polygon)<br>
</p>
<p>for input_feat in inputLayer.getFeatures():<br>
input_geom = input_feat.geometry()<br>
output_geom = input_geom.Intersection(clipPoly)<br>
# do something with output_geom, e.g. write to a layer</p>
Best regards,<br>
Lukas<br>
<br>
<div class="moz-cite-prefix">On 19.05.2017 16:02, Tudorache, Marian
wrote:<br>
</div>
<blockquote
cite="mid:4bcf544f03f145c19120c57801ac6e04@NCRMAIL3.corp.NAVCAN.CA"
type="cite">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 14 (filtered
medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 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.EmailStyle17
{mso-style-type:personal-reply;
font-family:"Calibri","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:72.0pt 72.0pt 72.0pt 72.0pt;}
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]-->
<div class="WordSection1">
<p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<div>
<div>
<div>
<div>
<p class="MsoNormal"><b><span
style="font-size:10.0pt;font-family:"Tahoma","sans-serif";color:#1F497D"
lang="EN-US">Hi,<o:p></o:p></span></b></p>
<p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">I
have tried to run clipping processing algorithm and
it fails.<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">First
version:<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">srs
= qgis.core.QgsCoordinateReferenceSystem(4019,
qgis.core. QgsCoordinateReferenceSystem.EpsgCrsId)<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">#Input
Layer<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">inputLayer
= qgis.core.QgsVectorLayer(shapeFileLocation +
“/inputLineString.shp”, “inputLineString”, “ogr”)<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">inputLayer.setCrs(srs)<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Clipping
Layer:
<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">clipLayer
=
qgis.core.QgsVectorLayer(“Polygon?crs={0}”.format(srs.authid())<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">#algorithm
to add a clipping polygon feature<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">#the
algorithm works because I tested with
clipLayer.getFeatures() and I was able to extract
the geometry and points<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">…..<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">….<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">#calling
processing algorithm.<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">processing.runalg(‘qgis.clip’,
inputLayer, clipLayer, “output.shp”)<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">The
error:<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Unable
to execute algorithm<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Wrong
parameter value: Polygon?crs=ESPG:4019<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Any
idea why is not working?<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Thank
you,<o:p></o:p></span></p>
<p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Marian<o:p></o:p></span></p>
</div>
</div>
</div>
</div>
</div>
<br>
<hr>
<font face="Arial" color="Gray" size="1"><br>
This electronic message, as well as any transmitted files
included in the electronic message, may contain privileged or
confidential information and is intended solely for the use of
the individual(s) or entity to which it is addressed. If you
have received this electronic message in error please notify the
sender immediately and delete the electronic message. Any
unauthorized copying, disclosure or distribution of the
electronic message is strictly forbidden. NAV CANADA accepts no
liability for any damage caused by any virus and/or other
malicious code transmitted by this electronic communication.<br>
<br>
Le présent message électronique et tout fichier qui peut y être
joint peuvent contenir des renseignements privilégiés ou
confidentiels destinés à l’usage exclusif des personnes ou des
organismes à qui ils s’adressent. Si vous avez reçu ce message
électronique par erreur, veuillez en informer l’expéditeur
immédiatement et supprimez le. Toute reproduction, divulgation
ou distribution du présent message électronique est strictement
interdite. NAV CANADA n’assume aucune responsabilité en cas de
dommage causé par tout virus ou autre programme malveillant
transmis par ce message électronique.<br>
</font>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
Qgis-user mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Qgis-user@lists.osgeo.org">Qgis-user@lists.osgeo.org</a>
List info: <a class="moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/qgis-user">https://lists.osgeo.org/mailman/listinfo/qgis-user</a>
Unsubscribe: <a class="moz-txt-link-freetext" href="https://lists.osgeo.org/mailman/listinfo/qgis-user">https://lists.osgeo.org/mailman/listinfo/qgis-user</a></pre>
</blockquote>
<br>
<pre class="moz-signature" cols="72">--
Lukas Winiwarter TU Wien,
Stud. Ass. Department of Geodesy and
Tel: +43-(0)1-58801-12246 Geoinformation (E120),
Fax: +43-(0)1-58801-912246 Research Group Photogrammetry
Email: <a class="moz-txt-link-abbreviated" href="mailto:lukas.winiwarter@tuwien.ac.at">lukas.winiwarter@tuwien.ac.at</a> Gußhausstraße 27-29
<a class="moz-txt-link-freetext" href="http://photo.geo.tuwien.ac.at/">http://photo.geo.tuwien.ac.at/</a> 1040 Vienna, Austria </pre>
</body>
</html>