Skip to content

Commit

Permalink
Remove mention of deprecated load() method and simplify description
Browse files Browse the repository at this point in the history
  • Loading branch information
DelazJ authored and github-actions[bot] committed May 15, 2024
1 parent 2c9f0f6 commit 8546313
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 19 deletions.
9 changes: 2 additions & 7 deletions docs/training_manual/processing/log.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ For instance, try the following:
#. Double-click on it and a new result should be produced,
just like when you run it using the normal dialog and calling it from the toolbox.

:abbr:`★★ (Advanced level)` Advanced
-------------------------------------
:abbr:`★★ (Moderate level)` Follow Along
------------------------------------------

You can also modify the algorithm.

Expand All @@ -62,8 +62,3 @@ You can also modify the algorithm.
#. Paste your copy to run the analysis; change the parameters at will.
#. To display the resulting file, you may want to replace ``processing.run`` in the pasted command
with ``processing.runAndLoadResults``.

Or, after you ran the pasted command, and depending on the output layer type, you can type e.g.::

iface.addVectorLayer('/path/to/output/filename', 'Layer name in legend', 'ogr')

32 changes: 20 additions & 12 deletions docs/user_manual/processing/console.rst
Original file line number Diff line number Diff line change
Expand Up @@ -309,13 +309,10 @@ appended to the given file path.

Unlike when an algorithm is executed from the toolbox, outputs are not
added to the map canvas if you execute that same algorithm from the
Python console using :meth:`run() <qgis.core.QgsProcessingAlgorithm.run>`,
but ``runAndLoadResults()`` will do that.

The :meth:`run() <qgis.core.QgsProcessingAlgorithm.run>` method returns
a dictionary with one or more output names (the
ones shown in the algorithm description) as keys and the file paths of
those outputs as values:
Python console using the :meth:`run() <qgis.core.QgsProcessingAlgorithm.run>` method.
That method returns a dictionary with one or more output names
(the ones shown in the algorithm description) as keys
and the file paths of those outputs as values:

.. code-block:: python
:linenos:
Expand All @@ -331,11 +328,22 @@ those outputs as values:
>>> myresult['OUTPUT']
/data/buffers.shp
You can load feature output by passing the corresponding file paths to
the ``load()`` method.
Or you could use ``runAndLoadResults()`` instead of
:meth:`run() <qgis.core.QgsProcessingAlgorithm.run>` to load
them immediately.
You can then load the output in the project as any common layer:

.. code-block:: python
:linenos:
>>> buffered_layer = myresult['OUTPUT']
>>> QgsProject.instance().addMapLayer(buffered_layer)
To immediately load the processing outputs in the project,
you can use the ``runAndLoadResults()`` method instead of ``run()``.

.. code-block:: python
:linenos:
>>> processing.runAndLoadResults("native:buffer", {parameters:values})
If you want to open an algorithm dialog from the console you can use the
``createAlgorithmDialog`` method. The only mandatory parameter is the algorithm
Expand Down

0 comments on commit 8546313

Please sign in to comment.