<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>as a starting point:</p>
<p><i>from qgis.core import *</i><i><br>
</i><i>from qgis.gui import *</i><i><br>
</i><i><br>
</i><i>@qgsfunction(args='auto', group='Custom',
referenced_columns=[])</i><i><br>
</i><i>def zCutBox(feature, parent):</i><i><br>
</i><i> """</i><i><br>
</i><i> Calculates vertices and return the x coordinate of the
first as string</i><i><br>
</i><i> """</i><i><br>
</i><i> geom = feature.geometry()</i><i><br>
</i><i> vertices = []</i><i><br>
</i><i> for v in geom.vertices():</i><i><br>
</i><i> vertices.append(v)</i><i><br>
</i><i> return str(vertices[0].x())</i><br>
</p>
<div class="moz-cite-prefix">Am 18.10.2021 um 13:42 schrieb Zoltan:<br>
</div>
<blockquote type="cite"
cite="mid:0e79d51e-27fa-92a9-f1e5-92e507557434@geograph.co.za">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
Hi Listers,<br>
I can't for the life of me work out the syntax/commands to use in
the FieldCalculator->FunctionEditor for extracting vertices.<br>
<br>
I have a Polygon layer with Multipolygon rectangles at various
rotations.<br>
I need to extract the 4 corner points so that I can calculate (and
save in a virtual layer) lines that I can later use with
"Processing->Split with lines".<br>
<br>
I will google for opening a new virtual layer and saving lines to
it, but if that is quick and easy then some help there would also
be welcome.<br>
<br>
Please can someone point me to a sample functions covering these
requirements, or just fill in the gaps below.<br>
No, I'm not asking for someone to just write it for me.<br>
<br>
Thanks in advance,<br>
Zoltan<br>
[Having a brain-dead day :-( ]<br>
<blockquote><br>
from qgis.core import *<br>
from qgis.gui import *<br>
<br>
@qgsfunction(args='auto', group='Custom', referenced_columns=[])<br>
def zCutBox(feature, parent):<br>
vertices = <br>
<br>
blah blah<br>
return vertices[0][0]<br>
</blockquote>
<br>
<pre class="moz-signature" cols="72">--
=============================================
Zoltan Szecsei GPrGISc 0031
Geograph (Pty) Ltd.
GIS and Photogrammetric Services
Cape Town, South Africa.
Mobile: +27-83-6004028 (Signal, not WhatsApp)
<a class="moz-txt-link-abbreviated" href="http://www.geograph.co.za" moz-do-not-send="true">www.geograph.co.za</a>
=============================================
</pre>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<pre class="moz-quote-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>
<pre class="moz-signature" cols="72">--
Mit freundlichen Grüßen
Stefan Giese
Projektleiter/Consultant
---------------------------------------------
Schon gewusst?
In unserem Blog geben wir Tipps & Tricks zu
Open-Source-GIS-Software und berichten aus unserem Experten-Alltag:
<a class="moz-txt-link-freetext" href="https://wheregroup.com/blog/">https://wheregroup.com/blog/</a>
---------------------------------------------
WhereGroup GmbH
Schwimmbadstr. 2
79100 Freiburg
Germany
Fon: +49 (0)761 / 519 102 - 61
Fax: +49 (0)761 / 519 102 - 11
<a class="moz-txt-link-abbreviated" href="mailto:stefan.giese@wheregroup.com">stefan.giese@wheregroup.com</a>
<a class="moz-txt-link-abbreviated" href="http://www.wheregroup.com">www.wheregroup.com</a>
Geschäftsführer:
Olaf Knopp, Peter Stamm
Amtsgericht Bonn, HRB 9885</pre>
</body>
</html>