[Qgis-user] [QGIS-Developer] processAlgorithm vs processFeature?

Etienne Trimaille etienne.trimaille at gmail.com
Tue Aug 24 23:47:25 PDT 2021


Indeed, if you can, you should use a QgsProcessingFeatureBasedAlgorithm
algorithm. It will make some shortcuts for you and the code is shorter
because you will only have a single feature to process.

Have a look to existing source code :
https://github.com/qgis/QGIS/search?q=QgsProcessingFeatureBasedAlgorithm

Le mar. 24 août 2021 à 04:55, Ujaval Gandhi <ujaval at spatialthoughts.com> a
écrit :

> 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
> https://spatialthoughts.com/2019/04/05/geodesic-buffers-in-qgis/
>
> On Mon, 23 Aug 2021 at 10:25 PM, C Hamilton <adenaculture at gmail.com>
> wrote:
>
>> 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.
>>
>> 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?
>>
>> Thanks,
>>
>> Calvin
>> _______________________________________________
>> Qgis-user mailing list
>> Qgis-user at lists.osgeo.org
>> List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
>> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
>>
> --
> [image: Logo] <https://spatialthoughts.com/>
> Ujaval Gandhi
> Spatial Thoughts
> mobile: +91-8095684687
> email: ujaval at spatialthoughts.com
> [image: LinkedIn icon] <https://www.linkedin.com/in/spatialthoughts/>  [image:
> Twitter icon] <https://twitter.com/spatialthoughts>
>
> _______________________________________________
> QGIS-Developer mailing list
> QGIS-Developer at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20210825/d7642a73/attachment.html>


More information about the Qgis-user mailing list