3

In the discussion from a question I asked several days ago (Using the processing framework in a PyQGIS standalone application), someone suggested that I use general.runalg() instead of processing.runalg() for running QGIS algorithms.

I've now used both, and haven't noticed a difference in either performance or syntax between them. I'm just wondering what sort of differences there are between these two methods, and which one I should be using.

4

Open a QGIS Python Console and run this:

import processing 
help( processing.runalg )

You will get:

Help on function runalg in module processing.tools.general:

runalg(algOrName, *args, **kwargs)

Which indicates us that by using processing.runalg(), you're actually calling general.runalg().

Note that if you want to call general.runalg() explicitly, you need to import the general module from processing.tools.

In summary, use whatever you want, just make sure you initialize Processing (Processing.initialize()) before calling runalg() if you're running a standalone PyQGIS script.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.