<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=utf-8"><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;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:"Segoe UI Emoji";
panose-1:2 11 5 2 4 2 4 2 2 3;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-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;}
p.msonormal0, li.msonormal0, div.msonormal0
{mso-style-name:msonormal;
mso-margin-top-alt:auto;
margin-right:0cm;
mso-margin-bottom-alt:auto;
margin-left:0cm;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
span.gmail-im
{mso-style-name:gmail-im;}
span.E-MailFormatvorlage19
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:windowtext;}
.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 2.0cm 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=DE link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span lang=EN-GB style='mso-fareast-language:EN-US'>Thanks for your answer, I feared that this might be an option after all. I will try Rudi’s answer first and then yours. I will definitely post my insights here so everyone can profit <o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB style='mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-GB style='mso-fareast-language:EN-US'>Frank<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-GB style='mso-fareast-language:EN-US'><o:p> </o:p></span></p><p class=MsoNormal><b>Von:</b> Jean-Baptiste Desbas <jb.desbas@gmail.com> <br><b>Gesendet:</b> Freitag, 29. Juni 2018 16:03<br><b>An:</b> Frank Broniewski <hallo@frankbroniewski.com><br><b>Cc:</b> Nyall Dawson <nyall.dawson@gmail.com>; qgis-user <qgis-user@lists.osgeo.org><br><b>Betreff:</b> Re: [Qgis-user] QGIS 3 Processing question<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><div><div><p class=MsoNormal>Hi, <o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>I had the same issue. I had to loop over the output vector layer (child alg) to feed the sink (main alg). Maybe is not the simpliest/shortest/fastest, but it works.<o:p></o:p></p></div><div><p class=MsoNormal>Something like that :<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>o <span class=gmail-im>= processing.run(</span><br><span class=gmail-im> 'qgis:pointsalonglines', </span><br><span class=gmail-im> params, context=context, feedback=feedback</span><br><span class=gmail-im> )['OUTPUT']</span> <o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal> (sink, dest_id) = self.parameterAsSink(<o:p></o:p></p></div><div><p class=MsoNormal> parameters,<br> self.OUTPUT,<br> context,<br> o.fields,<br> o.wkbType(),<br> o.sourceCrs()<br>)<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>for f in o.getFeatures()<o:p></o:p></p></div><div><p class=MsoNormal> sink.addFeature(f)<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>return {'OUTPUT':dest_id}<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div></div><div><p class=MsoNormal><o:p> </o:p></p><div><p class=MsoNormal>2018-06-29 9:35 GMT+02:00 Frank Broniewski <<a href="mailto:hallo@frankbroniewski.com" target="_blank">hallo@frankbroniewski.com</a>>:<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'><p class=MsoNormal>Hi Nyall,<br><br>thanks a ton for your response. I am well know for making things tricky for myself <span style='font-family:"Segoe UI Emoji",sans-serif'>😃</span><br>Anyway, my testing-algorithm-script is still not working. It runs through, but I do not get the expected result loaded into the layer tree. I suppose it runs through - the output from the 'qgis:pointsalonglines' is a QgsVectorLayer - but after finishing I get nuthink back.<br><br>Here's my complete script: You'll need a temporary polygon layer in a projected CRS (I use EPSG:31466) for it to work nicely. Copy & Paste it into a new script window and run it. I simply don't find the reason why the point result layer isn't loaded into my layer tree ...<br><br><br>from qgis.PyQt.QtCore import QCoreApplication<br>from qgis.core import (QgsApplication,<br> QgsProcessing,<br> QgsFeatureSink,<br> QgsProcessingAlgorithm,<br> QgsProcessingParameterFeatureSource,<br> QgsProcessingParameterNumber,<br> QgsProcessingParameterFeatureSink)<br><br>import processing<br><br><br>class PolygonCenterline(QgsProcessingAlgorithm):<br><br> INPUT = 'INPUT'<br> DISTANCE = 'DISTANCE'<br> OUTPUT = 'OUTPUT'<br><br> def tr(self, text):<br> return QCoreApplication.translate('Processing', text)<br><br> def createInstance(self):<br> return PolygonCenterline()<br><br> def group(self):<br> return <a href="http://self.tr" target="_blank">self.tr</a>('Cartography')<br><br> def groupId(self):<br> return 'cartography'<br><br> def name(self):<br> return 'polygoncenterline'<br><br> def displayName(self):<br> return <a href="http://self.tr" target="_blank">self.tr</a>('Calculate a polygon centerline')<br><br> def initAlgorithm(self, config=None):<br> self.addParameter(<br> QgsProcessingParameterFeatureSource(<br> self.INPUT,<br> <a href="http://self.tr" target="_blank">self.tr</a>('Vector Polygon Layer'),<br> [QgsProcessing.TypeVectorPolygon]<br> )<br> )<br><br> self.addParameter(<br> QgsProcessingParameterNumber(<br> self.DISTANCE,<br> <a href="http://self.tr" target="_blank">self.tr</a>('Point distance value'),<br> type=QgsProcessingParameterNumber.Double,<br> minValue=10.0<br> )<br> )<br><br> self.addParameter(<br> QgsProcessingParameterFeatureSink(<br> self.OUTPUT,<br> <a href="http://self.tr" target="_blank">self.tr</a>('Center line')<br> )<br> )<br><br> def processAlgorithm(self, parameters, context, feedback):<br> # qgis:pointsalonglines<br> params = {<br> 'INPUT': parameters[self.INPUT], <br> 'DISTANCE': parameters[self.DISTANCE],<br> 'START_OFFSET': 0,<br> 'END_OFFSET': 0,<br> 'OUTPUT': 'memory:'<br> }<br> points = processing.run(<br> 'qgis:pointsalonglines', <br> params, context=context, feedback=feedback<br> )['OUTPUT']<br><br> return {self.OUTPUT: points}<br><br><br><br><br>-----Ursprüngliche Nachricht-----<br>Von: Nyall Dawson <<a href="mailto:nyall.dawson@gmail.com">nyall.dawson@gmail.com</a>> <br>Gesendet: Freitag, 29. Juni 2018 01:04<br>An: Frank Broniewski <<a href="mailto:hallo@frankbroniewski.com">hallo@frankbroniewski.com</a>><br>Cc: qgis-user <<a href="mailto:qgis-user@lists.osgeo.org">qgis-user@lists.osgeo.org</a>><br>Betreff: Re: [Qgis-user] QGIS 3 Processing question<o:p></o:p></p><div><div><p class=MsoNormal><br>On Fri, 29 Jun 2018 at 07:14, Frank Broniewski <<a href="mailto:hallo@frankbroniewski.com">hallo@frankbroniewski.com</a>> wrote:<br>><br>> def processAlgorithm(self, parameters, context, feedback):<br><br><br>You're making this tricky for yourself! Cut out everything in processAlgorithm related to self.INPUT, and just pass the parameter value direct to the child algorithm to handle:<br><br>> params = {<br>><br>> 'INPUT': parameters[self.INPUT],<br>><br>> 'DISTANCE': pt_value,<br>><br>> 'START_OFFSET': 0,<br>><br>> 'END_OFFSET': 0,<br>><br>> 'OUTPUT': 'memory:'<br>><br>> }<br><br><br>Nyall<o:p></o:p></p></div></div><p class=MsoNormal><br>_______________________________________________<br>Qgis-user mailing list<br><a href="mailto:Qgis-user@lists.osgeo.org">Qgis-user@lists.osgeo.org</a><br>List info: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-user" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-user</a><br>Unsubscribe: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-user" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-user</a><o:p></o:p></p></blockquote></div><p class=MsoNormal><o:p> </o:p></p></div></div></body></html>