<div dir="ltr"><div>Indeed, if you can, you should use a <span class="gmail-pl-en">QgsProcessingFeatureBasedAlgorithm algorithm. It will make some shortcuts for you and the code is shorter because you will only have a single feature to process.<br></span></div><div><br></div><div>Have a look to existing source code : <a href="https://github.com/qgis/QGIS/search?q=QgsProcessingFeatureBasedAlgorithm">https://github.com/qgis/QGIS/search?q=QgsProcessingFeatureBasedAlgorithm</a></div><div><span class="gmail-pl-en"></span></div><div><span class="gmail-pl-en"></span></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Le mar. 24 août 2021 à 04:55, Ujaval Gandhi <<a href="mailto:ujaval@spatialthoughts.com">ujaval@spatialthoughts.com</a>> a écrit :<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto">If your algorithm works on each feature independently, processFeature() is preferred. If you need to work with layers, you need to use processAlgorithm(). I demonstrate this with an example at <div><a href="https://spatialthoughts.com/2019/04/05/geodesic-buffers-in-qgis/" target="_blank">https://spatialthoughts.com/2019/04/05/geodesic-buffers-in-qgis/</a></div></div><div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, 23 Aug 2021 at 10:25 PM, C Hamilton <<a href="mailto:adenaculture@gmail.com" target="_blank">adenaculture@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">I discovered that it looks like there is another way to deal with processing algorithms. Rather than use processAlgorithm it looks like I can use prepareAlgorithm & processFeature. I have always used processAlgorithm and then iterated through the features. <div><br></div><div>Is processFeature just as quick as using processAlgorithm (iterating through the features)? Is one method preferred over the other? I think for some algorithms using processFeature would make the code look cleaner. Are there any gotchas in using the processFeature method?</div><div><br></div><div>Thanks,</div><div><br></div><div>Calvin</div></div>
_______________________________________________<br>
Qgis-user mailing list<br>
<a href="mailto:Qgis-user@lists.osgeo.org" target="_blank">Qgis-user@lists.osgeo.org</a><br>
List info: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-user" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-user</a><br>
Unsubscribe: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-user" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-user</a><br>
</blockquote></div></div>-- <br><div dir="ltr"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div></div><div><table style="border-spacing:0px;border-collapse:collapse;color:rgb(68,68,68);width:480px;font-size:10pt;font-family:Arial,sans-serif;line-height:normal" cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:10px 0px 12px;width:160px;vertical-align:top" valign="top"><a href="https://spatialthoughts.com/" style="background-color:transparent;color:rgb(51,122,183)" target="_blank"><img alt="Logo" src="https://spatialthoughts685850346.files.wordpress.com/2019/12/spatial_thoughts_logo.png" style="border: 0px none; vertical-align: middle; width: 141px; height: auto;" width="141" border="0"></a></td><td style="padding:6px 0px;width:320px"><table style="border-spacing:0px;border-collapse:collapse;background-color:transparent" cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:0px;font-size:12pt;font-family:Arial,sans-serif;font-weight:bold;color:rgb(61,60,63)"><span style="color:rgb(0,175,239)">Ujaval Gandhi</span></td></tr><tr><td style="padding:0px 0px 11px;font-size:10pt;font-family:Arial,sans-serif;color:rgb(61,60,63)"><span style="color:rgb(0,175,239)">Spatial Thoughts</span></td></tr><tr><td style="padding:0px;font-size:10pt;font-family:Arial,sans-serif;color:rgb(155,155,155)"><span>mobile: +91-8095684687</span></td></tr><tr><td style="padding:0px;font-size:10pt;font-family:Arial,sans-serif;color:rgb(155,155,155)"><span>email: </span><span style="color:rgb(23,147,210)"><a href="mailto:ujaval@spatialthoughts.com" target="_blank">ujaval@spatialthoughts.com</a></span></td></tr><tr><td style="padding:6px 0px 0px"><span style="display:inline-block;height:22px"><span><a href="https://www.linkedin.com/in/spatialthoughts/" style="background-color:transparent;color:rgb(51,122,183)" target="_blank"><img alt="LinkedIn icon" src="https://codetwocdn.azureedge.net/images/mail-signatures/generator/elegant-logo/ln.png" style="border: 0px none; vertical-align: middle; height: 20px; width: 20px;" width="23" height="23" border="0"></a>  </span><span><a href="https://twitter.com/spatialthoughts" style="background-color:transparent;color:rgb(51,122,183)" target="_blank"><img alt="Twitter icon" src="https://codetwocdn.azureedge.net/images/mail-signatures/generator/elegant-logo/tt.png" style="border: 0px none; vertical-align: middle; height: 20px; width: 20px;" width="23" height="23" border="0"></a>  </span></span></td></tr></tbody></table></td></tr><tr><td colspan="2" style="padding:8px 0px 0px;border-top:1px solid rgb(23,147,210);width:480px;font-family:Arial,sans-serif;color:rgb(155,155,155);text-align:justify"></td></tr></tbody></table><br></div></div></div></div></div></div></div></div></div></div></div>
_______________________________________________<br>
QGIS-Developer mailing list<br>
<a href="mailto:QGIS-Developer@lists.osgeo.org" target="_blank">QGIS-Developer@lists.osgeo.org</a><br>
List info: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br>
Unsubscribe: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-developer" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br>
</blockquote></div>