How to create a new QGIS plugin from scratch?

How to create a new QGIS plugin from scratch?

To create a plugin from scratch which contains an algorithm provider, you can follow these steps using the Plugin Builder: Create a new plugin using the Plugin Builder. When the Plugin Builder asks you for the template to use, select “Processing provider”. The created plugin contains a provider with a single algorithm.

Is there a way to run QGIS from toolbox?

If ran from toolbox, this works fine, because you can tick the “Open output file after running algorithm” box. Looking at the source code for QGIS, the code for loading the memory layer seems to be defined in the function Postprocessing.handleAlgorithmResults.

How to add a processing plugin to Python?

If you want to add your existing plugin to Processing, you need to add some code. In your metadata.txt file, you need to add a variable: In the Python file where your plugin is setup with the initGui method, you need to adapt some lines like this: You can create a folder processing_provider with three files in it: __init__.py with nothing in it.

Where do I find the source of qgsvector?

If its the latter you could easily query loaded QGsVector- and QGsRasterlayer objects by looking into the QGIS MapLayer registry. In general all layers must have a source somewhere on the harddrive even if the result is just added after a processing-alg finishes its calculations.

Is there a processing console in QGIS Python?

There is not a processing console in QGIS, but all processing commands are available instead from the QGIS built-in Python console. That means that you can incorporate those commands into your console work and connect processing algorithms to all the other features (including methods from the QGIS API) available from there.

Why do algorithms run in a separate thread in QGIS?

By default, Processing runs algorithms in a separate thread in order to keep QGIS responsive while the processing task runs. If your algorithm is regularly crashing, you are probably using API calls which are not safe to do in a background thread.

Can a processing script extend a qgsprocessingalgorithm?

Processing scripts extend QgsProcessingAlgorithm, so you need to add some extra lines of code to implement mandatory functions.