2

For older versions of QGIS, the algorithm parameters were documented in the 'Console usage' section in the QGIS documentation (e.g. the reproject layer documentation). In the QGIS 3 documentation (e.g. reproject layer documentation) there is no 'Console usage' section. Where can I find out how to use the algorithms in my scripts, especially since many of them have changed?

2

Edit: See also the answer to QGIS 3.0 Error when calling processing.runalg() which is also a complete answer to this question.

I found that the easiest way to get documentation on the algorithms is to use processing.algorithmHelp from the QGIS Python Console (enable with Plugins > Python Console). For example, typing processing.algorithmHelp("native:reprojectlayer") into the interactive console gives this documentation:

Reproject layer (native:reprojectlayer)

This algorithm reprojects a vector layer. It creates a new layer with the same features as the input one, but with geometries reprojected to a new CRS.

Attributes are not modified by this algorithm.


----------------
Input parameters
----------------

INPUT: Input layer

    Parameter type: QgsProcessingParameterFeatureSource

    Accepted data types:
        - str: layer ID
        - str: layer name
        - str: layer source
        - QgsProcessingFeatureSourceDefinition
        - QgsProperty
        - QgsVectorLayer

TARGET_CRS: Target CRS

    Parameter type: QgsProcessingParameterCrs

    Accepted data types:
        - str: 'ProjectCrs'
        - str: CRS auth ID (e.g. 'EPSG:3111')
        - str: CRS PROJ4 (e.g. 'PROJ4:...')
        - str: CRS WKT (e.g. 'WKT:...')
        - str: layer ID. CRS of layer is used.
        - str: layer name. CRS of layer is used.
        - str: layer source. CRS of layer is used.
        - QgsMapLayer: CRS of layer is used
        - QgsProcessingFeatureSourceDefinition: CRS of source is used
        - QgsProperty

OUTPUT: Reprojected

    Parameter type: QgsProcessingParameterFeatureSink

    Accepted data types:
        - str: destination vector file, e.g. 'd:/test.shp'
        - str: 'memory:' to store result in temporary memory layer
        - str: using vector provider ID prefix and destination URI, e.g. 'postgres:...' to store result in PostGIS table
        - QgsProcessingOutputLayerDefinition
        - QgsProperty

----------------
Outputs
----------------

OUTPUT:  <QgsProcessingOutputVectorLayer>
    Reprojected

To figure out what the algorithm identifier is (e.g. native:reprojectlayer) you can run the algorithm from the toolbox, and then check in the history to see the name (and you what parameters were passed).

Checking the algorithm history

Another way to get the algorithm identifier is to hover your mouse over one of the algorithms in the toolbox.

enter image description here

| improve this answer | |

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.