Class: QgsProcessingParameters

A collection of utilities for working with parameters when running a processing algorithm.

Parameters are stored in a QVariantMap and referenced by a unique string key. The QVariants in parameters are not usually accessed directly, and instead the high level API provided through QgsProcessingParameters parameterAsString(), parameterAsDouble() are used instead.

Parameters are evaluated using a provided QgsProcessingContext, allowing the evaluation to understand available map layers and expression contexts (for expression based parameters).

Static Methods

descriptionFromName

Creates an autogenerated parameter description from a parameter name.

isDynamic

Returns True if the parameter with matching name is a dynamic parameter, and must be evaluated once for every input feature processed.

parameterAsAnnotationLayer

Evaluates the parameter with matching definition to an annotation layer.

parameterAsBool

Evaluates the parameter with matching definition to a static boolean value.

parameterAsBoolean

Evaluates the parameter with matching definition to a static boolean value.

parameterAsColor

Returns the color associated with an point parameter value, or an invalid color if the parameter was not set.

parameterAsCompatibleSourceLayerPath

Evaluates the parameter with matching definition to a source vector layer file path of compatible format.

parameterAsCompatibleSourceLayerPathAndLayerName

Evaluates the parameter with matching definition to a source vector layer file path and layer name of compatible format.

parameterAsConnectionName

Evaluates the parameter with matching definition to a connection name string.

parameterAsCrs

Evaluates the parameter with matching definition to a coordinate reference system.

parameterAsDatabaseTableName

Evaluates the parameter with matching definition to a database table name.

parameterAsDate

Evaluates the parameter with matching definition to a static date value.

parameterAsDateTime

Evaluates the parameter with matching definition to a static datetime value.

parameterAsDouble

Evaluates the parameter with matching definition to a static double value.

parameterAsEnum

Evaluates the parameter with matching definition to a enum value.

parameterAsEnumString

Evaluates the parameter with matching definition to a static enum string.

parameterAsEnumStrings

Evaluates the parameter with matching definition to list of static enum strings.

parameterAsEnums

Evaluates the parameter with matching definition to list of enum values.

parameterAsExpression

Evaluates the parameter with matching definition to an expression.

parameterAsExtent

Evaluates the parameter with matching definition to a rectangular extent.

parameterAsExtentCrs

Returns the coordinate reference system associated with an extent parameter value.

parameterAsExtentGeometry

Evaluates the parameter with matching definition to a rectangular extent, and returns a geometry covering this extent.

parameterAsFields

Evaluates the parameter with matching definition to a list of fields.

parameterAsFile

Evaluates the parameter with matching definition to a file/folder name.

parameterAsFileList

Evaluates the parameter with matching definition to a list of files (for QgsProcessingParameterMultipleLayers in QgsProcessing:TypeFile mode).

parameterAsFileOutput

Evaluates the parameter with matching definition to a file based output destination.

parameterAsGeometry

Evaluates the parameter with matching definition to a geometry.

parameterAsGeometryCrs

Returns the coordinate reference system associated with a geometry parameter value.

parameterAsInt

Evaluates the parameter with matching definition to a static integer value.

parameterAsInts

Evaluates the parameter with matching definition to a list of integer values.

parameterAsLayer

Evaluates the parameter with matching definition to a map layer.

parameterAsLayerList

Evaluates the parameter with matching definition to a list of map layers.

parameterAsLayout

Evaluates the parameter with matching definition to a print layout.

parameterAsLayoutItem

Evaluates the parameter with matching definition to a print layout item, taken from the specified layout.

parameterAsMatrix

Evaluates the parameter with matching definition to a matrix/table of values.

parameterAsMeshLayer

Evaluates the parameter with matching definition and value to a mesh layer.

parameterAsOutputLayer

Evaluates the parameter with matching definition to a output layer destination.

parameterAsPoint

Evaluates the parameter with matching definition to a point.

parameterAsPointCloudLayer

Evaluates the parameter with matching definition to a point cloud layer.

parameterAsPointCrs

Returns the coordinate reference system associated with an point parameter value.

parameterAsRange

Evaluates the parameter with matching definition to a range of values.

parameterAsRasterLayer

Evaluates the parameter with matching definition to a raster layer.

parameterAsSchema

Evaluates the parameter with matching definition to a database schema name.

parameterAsSink

Evaluates the parameter with matching definition to a feature sink.

parameterAsSource

Evaluates the parameter with matching definition to a feature source.

parameterAsString

Evaluates the parameter with matching definition to a static string value.

parameterAsStrings

Evaluates the parameter with matching definition to a list of strings (e.g. field names or point cloud attributes).

parameterAsTime

Evaluates the parameter with matching definition to a static time value.

parameterAsVectorLayer

Evaluates the parameter with matching definition to a vector layer.

parameterFromScriptCode

Creates a new QgsProcessingParameterDefinition using the configuration from a supplied script code string.

parameterFromVariantMap

Creates a new QgsProcessingParameterDefinition using the configuration from a supplied variant map.

class qgis.core.QgsProcessingParameters[source]

Bases: object

static descriptionFromName(name: str | None) str[source]

Creates an autogenerated parameter description from a parameter name.

Parameters:

name (Optional[str])

Return type:

str

static isDynamic(parameters: Dict[str, Any], name: str | None) bool[source]

Returns True if the parameter with matching name is a dynamic parameter, and must be evaluated once for every input feature processed.

Parameters:
  • parameters (Dict[str, Any])

  • name (Optional[str])

Return type:

bool

static parameterAsAnnotationLayer(definition: QgsProcessingParameterDefinition | None, parameters: Dict[str, Any], context: QgsProcessingContext) QgsAnnotationLayer | None[source]

Evaluates the parameter with matching definition to an annotation layer.

Layers will be taken from context’s active project. Callers do not need to handle deletion of the returned layer.

Warning

Working with annotation layers is generally not thread safe (unless the layers are from a QgsProject loaded directly in a background thread). Ensure your algorithm returns the QgsProcessingAlgorithm.FlagNoThreading flag or only accesses annotation layers from a prepareAlgorithm() or postProcessAlgorithm() step.

Added in version 3.22.

Parameters:
Return type:

Optional[QgsAnnotationLayer]

static parameterAsAnnotationLayer(definition: QgsProcessingParameterDefinition | None, value: Any, context: QgsProcessingContext) QgsAnnotationLayer | None[source]

Evaluates the parameter with matching definition and value to an annotation layer.

Layers will be taken from context’s active project. Callers do not need to handle deletion of the returned layer.

Warning

Working with annotation layers is generally not thread safe (unless the layers are from a QgsProject loaded directly in a background thread). Ensure your algorithm returns the QgsProcessingAlgorithm.FlagNoThreading flag or only accesses annotation layers from a prepareAlgorithm() or postProcessAlgorithm() step.

Added in version 3.22.

Parameters:
Return type:

Optional[QgsAnnotationLayer]

static parameterAsBool(definition: QgsProcessingParameterDefinition | None, parameters: Dict[str, Any], context: QgsProcessingContext) bool[source]

Evaluates the parameter with matching definition to a static boolean value.

Parameters:
Return type:

bool

static parameterAsBool(definition: QgsProcessingParameterDefinition | None, value: Any, context: QgsProcessingContext) bool[source]

Evaluates the parameter with matching definition and value to a static boolean value.

Added in version 3.4.

Parameters:
Return type:

bool

static parameterAsBoolean(definition: QgsProcessingParameterDefinition | None, parameters: Dict[str, Any], context: QgsProcessingContext) bool[source]

Evaluates the parameter with matching definition to a static boolean value.

Added in version 3.8.

Parameters:
Return type:

bool

static parameterAsBoolean(definition: QgsProcessingParameterDefinition | None, value: Any, context: QgsProcessingContext) bool[source]

Evaluates the parameter with matching definition and value to a static boolean value.

Added in version 3.8.

Parameters:
Return type:

bool

static parameterAsColor(definition: QgsProcessingParameterDefinition | None, parameters: Dict[str, Any], context: QgsProcessingContext) QColor[source]

Returns the color associated with an point parameter value, or an invalid color if the parameter was not set.

Added in version 3.10.

Parameters:
Return type:

QColor

static parameterAsColor(definition: QgsProcessingParameterDefinition | None, value: Any, context: QgsProcessingContext) QColor[source]

Returns the color associated with an color parameter value, or an invalid color if the parameter was not set.

Added in version 3.10.

Parameters:
Return type:

QColor

static parameterAsCompatibleSourceLayerPath(definition: QgsProcessingParameterDefinition | None, parameters: Dict[str, Any], context: QgsProcessingContext, compatibleFormats: Iterable[str | None], preferredFormat: str | None = '', feedback: QgsProcessingFeedback | None = None) str[source]

Evaluates the parameter with matching definition to a source vector layer file path of compatible format.

If the parameter is evaluated to an existing layer, and that layer is not of the format listed in the compatibleFormats argument, then the layer will first be exported to a compatible format in a temporary location. The function will then return the path to that temporary file.

compatibleFormats should consist entirely of lowercase file extensions, e.g. ‘shp’.

The preferredFormat argument is used to specify to desired file extension to use when a temporary layer export is required. This defaults to shapefiles, because shapefiles are the future (don’t believe the geopackage hype!).

When an algorithm is capable of handling multi-layer input files (such as Geopackage), it is preferable to use parameterAsCompatibleSourceLayerPathAndLayerName() which may avoid conversion in more situations.

Parameters:
Return type:

str

static parameterAsCompatibleSourceLayerPathAndLayerName(definition: QgsProcessingParameterDefinition | None, parameters: Dict[str, Any], context: QgsProcessingContext, compatibleFormats: Iterable[str | None], preferredFormat: str | None = '', feedback: QgsProcessingFeedback | None = None)[source]

Evaluates the parameter with matching definition to a source vector layer file path and layer name of compatible format.

If the parameter is evaluated to an existing layer, and that layer is not of the format listed in the compatibleFormats argument, then the layer will first be exported to a compatible format in a temporary location. The function will then return the path to that temporary file.

compatibleFormats should consist entirely of lowercase file extensions, e.g. ‘shp’.

The preferredFormat argument is used to specify to desired file extension to use when a temporary layer export is required. This defaults to shapefiles, because shapefiles are the future (don’t believe the geopackage hype!).

This method should be preferred over parameterAsCompatibleSourceLayerPath() when an algorithm is able to correctly handle files with multiple layers. Unlike parameterAsCompatibleSourceLayerPath(), it will not force a conversion in this case and will return the target layer name in the layerName argument.

Parameters:
  • definition (Optional[QgsProcessingParameterDefinition]) – associated parameter definition

  • parameters (Dict[str, Any]) – input parameter value map

  • context (QgsProcessingContext) – processing context

  • compatibleFormats (Iterable[Optional[str]]) – a list of lowercase file extensions compatible with the algorithm

  • preferredFormat (Optional[str] = '') – preferred format extension to use if conversion if required

  • feedback (Optional[QgsProcessingFeedback] = None) -> (str) – feedback object

Returns:

  • path to source layer, or nearly converted compatible layer

  • layerName: the target layer name for multi-layer sources (e.g. Geopackage)

Added in version 3.10.

static parameterAsConnectionName(definition: QgsProcessingParameterDefinition | None, parameters: Dict[str, Any], context: QgsProcessingContext) str[source]

Evaluates the parameter with matching definition to a connection name string.

Added in version 3.14.

Parameters:
Return type:

str

static parameterAsConnectionName(definition: QgsProcessingParameterDefinition | None, value: Any, context: QgsProcessingContext) str[source]

Evaluates the parameter with matching definition and value to a connection name string.

Added in version 3.14.

Parameters:
Return type:

str

static parameterAsCrs(definition: QgsProcessingParameterDefinition | None, parameters: Dict[str, Any], context: QgsProcessingContext) QgsCoordinateReferenceSystem[source]

Evaluates the parameter with matching definition to a coordinate reference system.

Parameters:
Return type:

QgsCoordinateReferenceSystem

static parameterAsCrs(definition: QgsProcessingParameterDefinition | None, value: Any, context: QgsProcessingContext) QgsCoordinateReferenceSystem[source]

Evaluates the parameter with matching definition and value to a coordinate reference system.

Added in version 3.4.

Parameters:
Return type:

QgsCoordinateReferenceSystem

static parameterAsDatabaseTableName(definition: QgsProcessingParameterDefinition | None, parameters: Dict[str, Any], context: QgsProcessingContext) str[source]

Evaluates the parameter with matching definition to a database table name.

Added in version 3.14.

Parameters:
Return type:

str

static parameterAsDatabaseTableName(definition: QgsProcessingParameterDefinition | None, value: Any, context: QgsProcessingContext) str[source]

Evaluates the parameter with matching definition and value to a database table name.

Added in version 3.14.

Parameters:
Return type:

str

static parameterAsDate(definition: QgsProcessingParameterDefinition | None, parameters: Dict[str, Any], context: QgsProcessingContext) QDate[source]

Evaluates the parameter with matching definition to a static date value.

Added in version 3.14.

Parameters:
Return type:

QDate

static parameterAsDate(definition: QgsProcessingParameterDefinition | None, value: Any, context: QgsProcessingContext) QDate[source]

Evaluates the parameter with matching definition and value to a static date value.

Added in version 3.14.

Parameters:
Return type:

QDate

static parameterAsDateTime(definition: QgsProcessingParameterDefinition | None, parameters: Dict[str, Any], context: QgsProcessingContext) QDateTime[source]

Evaluates the parameter with matching definition to a static datetime value.

Added in version 3.14.

Parameters:
Return type:

QDateTime

static parameterAsDateTime(definition: QgsProcessingParameterDefinition | None, value: Any, context: QgsProcessingContext) QDateTime[source]

Evaluates the parameter with matching definition and value to a static datetime value.

Added in version 3.14.

Parameters:
Return type:

QDateTime

static parameterAsDouble(definition: QgsProcessingParameterDefinition | None, parameters: Dict[str, Any], context: QgsProcessingContext) float[source]

Evaluates the parameter with matching definition to a static double value.

Parameters:
Return type:

float

static parameterAsDouble(definition: QgsProcessingParameterDefinition | None, value: Any, context: QgsProcessingContext) float[source]

Evaluates the parameter with matching definition and value to a static double value.

Added in version 3.4.

Parameters:
Return type:

float

static parameterAsEnum(definition: QgsProcessingParameterDefinition | None, parameters: Dict[str, Any], context: QgsProcessingContext) int[source]

Evaluates the parameter with matching definition to a enum value.

Parameters:
Return type:

int

static parameterAsEnum(definition: QgsProcessingParameterDefinition | None, value: Any, context: QgsProcessingContext) int[source]

Evaluates the parameter with matching definition and value to a enum value.

Added in version 3.4.

Parameters:
Return type:

int

static parameterAsEnumString(definition: QgsProcessingParameterDefinition | None, parameters: Dict[str, Any], context: QgsProcessingContext) str[source]

Evaluates the parameter with matching definition to a static enum string.

Added in version 3.18.

Parameters:
Return type:

str

static parameterAsEnumString(definition: QgsProcessingParameterDefinition | None, value: Any, context: QgsProcessingContext) str[source]

Evaluates the parameter with matching definition and value to a static enum string.

Added in version 3.18.

Parameters:
Return type:

str

static parameterAsEnumStrings(definition: QgsProcessingParameterDefinition | None, parameters: Dict[str, Any], context: QgsProcessingContext) List[str][source]

Evaluates the parameter with matching definition to list of static enum strings.

Added in version 3.18.

Parameters:
Return type:

List[str]

static parameterAsEnumStrings(definition: QgsProcessingParameterDefinition | None, value: Any, context: QgsProcessingContext) List[str][source]

Evaluates the parameter with matching definition and value to list of static enum strings.

Added in version 3.18.

Parameters:
Return type:

List[str]

static parameterAsEnums(definition: QgsProcessingParameterDefinition | None, parameters: Dict[str, Any], context: QgsProcessingContext) List[int]

Evaluates the parameter with matching definition to list of enum values.

Parameters:
Return type:

List[int]

static parameterAsEnums(definition: QgsProcessingParameterDefinition | None, value: Any, context: QgsProcessingContext) List[int]

Evaluates the parameter with matching definition and value to list of enum values.

Added in version 3.4.

Parameters:
Return type:

List[int]

static parameterAsExpression(definition: QgsProcessingParameterDefinition | None, parameters: Dict[str, Any], context: QgsProcessingContext) str[source]

Evaluates the parameter with matching definition to an expression.

Parameters:
Return type:

str

static parameterAsExpression(definition: QgsProcessingParameterDefinition | None, value: Any, context: QgsProcessingContext) str[source]

Evaluates the parameter with matching definitionand value to an expression.

Added in version 3.4.

Parameters:
Return type:

str

static parameterAsExtent(definition: QgsProcessingParameterDefinition | None, parameters: Dict[str, Any], context: QgsProcessingContext, crs: QgsCoordinateReferenceSystem = QgsCoordinateReferenceSystem()) QgsRectangle[source]

Evaluates the parameter with matching definition to a rectangular extent.

If crs is set, and the original coordinate reference system of the parameter can be determined, then the extent will be automatically reprojected so that it is in the specified crs. In this case the extent of the reproject rectangle will be returned.

Parameters:
Return type:

QgsRectangle

static parameterAsExtent(definition: QgsProcessingParameterDefinition | None, value: Any, context: QgsProcessingContext, crs: QgsCoordinateReferenceSystem = QgsCoordinateReferenceSystem()) QgsRectangle[source]

Evaluates the parameter with matching definition and value to a rectangular extent.

If crs is set, and the original coordinate reference system of the parameter can be determined, then the extent will be automatically reprojected so that it is in the specified crs. In this case the extent of the reproject rectangle will be returned.

Added in version 3.4.

Parameters:
Return type:

QgsRectangle

static parameterAsExtentCrs(definition: QgsProcessingParameterDefinition | None, parameters: Dict[str, Any], context: QgsProcessingContext) QgsCoordinateReferenceSystem[source]

Returns the coordinate reference system associated with an extent parameter value.

Parameters:
Return type:

QgsCoordinateReferenceSystem

static parameterAsExtentCrs(definition: QgsProcessingParameterDefinition | None, value: Any, context: QgsProcessingContext) QgsCoordinateReferenceSystem[source]

Returns the coordinate reference system associated with an extent parameter value.

Parameters:
Return type:

QgsCoordinateReferenceSystem

static parameterAsExtentGeometry(definition: QgsProcessingParameterDefinition | None, parameters: Dict[str, Any], context: QgsProcessingContext, crs: QgsCoordinateReferenceSystem = QgsCoordinateReferenceSystem()) QgsGeometry[source]

Evaluates the parameter with matching definition to a rectangular extent, and returns a geometry covering this extent.

If crs is set, and the original coordinate reference system of the parameter can be determined, then the extent will be automatically reprojected so that it is in the specified crs. Unlike parameterAsExtent(), the reprojected rectangle returned by this function will no longer be a rectangle itself (i.e. this method returns the geometry of the actual reprojected rectangle, while parameterAsExtent() returns just the extent of the reprojected rectangle).

Parameters:
Return type:

QgsGeometry

static parameterAsFields(definition: QgsProcessingParameterDefinition | None, parameters: Dict[str, Any], context: QgsProcessingContext) List[str][source]

Evaluates the parameter with matching definition to a list of fields.

Deprecated since version 3.40: Use parameterAsStrings() instead.

Parameters:
Return type:

List[str]

static parameterAsFields(definition: QgsProcessingParameterDefinition | None, value: Any, context: QgsProcessingContext) List[str][source]

Evaluates the parameter with matching definition and value to a list of fields.

Added in version 3.4.

Deprecated since version 3.40: Use parameterAsStrings() instead.

Parameters:
Return type:

List[str]

static parameterAsFile(definition: QgsProcessingParameterDefinition | None, parameters: Dict[str, Any], context: QgsProcessingContext) str[source]

Evaluates the parameter with matching definition to a file/folder name.

Parameters:
Return type:

str

static parameterAsFile(definition: QgsProcessingParameterDefinition | None, value: Any, context: QgsProcessingContext) str[source]

Evaluates the parameter with matching definition and value to a file/folder name.

Added in version 3.4.

Parameters:
Return type:

str

static parameterAsFileList(definition: QgsProcessingParameterDefinition | None, value: Any, context: QgsProcessingContext) List[str][source]

Evaluates the parameter with matching definition to a list of files (for QgsProcessingParameterMultipleLayers in QgsProcessing:TypeFile mode).

Added in version 3.10.

Parameters:
Return type:

List[str]

static parameterAsFileList(definition: QgsProcessingParameterDefinition | None, parameters: Dict[str, Any], context: QgsProcessingContext) List[str][source]

Evaluates the parameter with matching definition to a list of files (for QgsProcessingParameterMultipleLayers in QgsProcessing:TypeFile mode).

Added in version 3.10.

Parameters:
Return type:

List[str]

static parameterAsFileOutput(definition: QgsProcessingParameterDefinition | None, parameters: Dict[str, Any], context: QgsProcessingContext) str[source]

Evaluates the parameter with matching definition to a file based output destination.

Parameters:
Return type:

str

static parameterAsFileOutput(definition: QgsProcessingParameterDefinition | None, value: Any, context: QgsProcessingContext) str[source]

Evaluates the parameter with matching definition and value to a file based output destination.

Added in version 3.4.

Parameters:
Return type:

str

static parameterAsGeometry(definition: QgsProcessingParameterDefinition | None, parameters: Dict[str, Any], context: QgsProcessingContext, crs: QgsCoordinateReferenceSystem = QgsCoordinateReferenceSystem()) QgsGeometry[source]

Evaluates the parameter with matching definition to a geometry.

Added in version 3.16.

Parameters:
Return type:

QgsGeometry

static parameterAsGeometry(definition: QgsProcessingParameterDefinition | None, value: Any, context: QgsProcessingContext, crs: QgsCoordinateReferenceSystem = QgsCoordinateReferenceSystem()) QgsGeometry[source]

Evaluates the parameter with matching definition and value to a geometry.

Added in version 3.16.

Parameters:
Return type:

QgsGeometry

static parameterAsGeometryCrs(definition: QgsProcessingParameterDefinition | None, parameters: Dict[str, Any], context: QgsProcessingContext) QgsCoordinateReferenceSystem[source]

Returns the coordinate reference system associated with a geometry parameter value.

Added in version 3.16.

Parameters:
Return type:

QgsCoordinateReferenceSystem

static parameterAsGeometryCrs(definition: QgsProcessingParameterDefinition | None, value: Any, context: QgsProcessingContext) QgsCoordinateReferenceSystem[source]

Returns the coordinate reference system associated with an point parameter value.

Added in version 3.16.

Parameters:
Return type:

QgsCoordinateReferenceSystem

static parameterAsInt(definition: QgsProcessingParameterDefinition | None, parameters: Dict[str, Any], context: QgsProcessingContext) int[source]

Evaluates the parameter with matching definition to a static integer value.

Parameters:
Return type:

int

static parameterAsInt(definition: QgsProcessingParameterDefinition | None, value: Any, context: QgsProcessingContext) int[source]

Evaluates the parameter with matching definition and value to a static integer value.

Added in version 3.4.

Parameters:
Return type:

int

static parameterAsInts(definition: QgsProcessingParameterDefinition | None, parameters: Dict[str, Any], context: QgsProcessingContext) List[int]

Evaluates the parameter with matching definition to a list of integer values.

Added in version 3.4.

Parameters:
Return type:

List[int]

static parameterAsInts(definition: QgsProcessingParameterDefinition | None, value: Any, context: QgsProcessingContext) List[int]

Evaluates the parameter with matching definition and value to a list of integer values.

Added in version 3.4.

Parameters:
Return type:

List[int]

static parameterAsLayer(definition: QgsProcessingParameterDefinition | None, parameters: Dict[str, Any], context: QgsProcessingContext, layerHint: QgsProcessingUtils.LayerHint = QgsProcessingUtils.LayerHint.UnknownType, flags: QgsProcessing.LayerOptionsFlags | QgsProcessing.LayerOptionsFlag = QgsProcessing.LayerOptionsFlags()) QgsMapLayer | None[source]

Evaluates the parameter with matching definition to a map layer.

Layers will either be taken from context’s active project, or loaded from external sources and stored temporarily in the context. In either case, callers do not need to handle deletion of the returned layer.

Parameters:
Return type:

Optional[QgsMapLayer]

static parameterAsLayer(definition: QgsProcessingParameterDefinition | None, value: Any, context: QgsProcessingContext, layerHint: QgsProcessingUtils.LayerHint = QgsProcessingUtils.LayerHint.UnknownType, flags: QgsProcessing.LayerOptionsFlags | QgsProcessing.LayerOptionsFlag = QgsProcessing.LayerOptionsFlags()) QgsMapLayer | None[source]

Evaluates the parameter with matching definition and value to a map layer.

Layers will either be taken from context’s active project, or loaded from external sources and stored temporarily in the context. In either case, callers do not need to handle deletion of the returned layer.

Added in version 3.4.

Parameters:
Return type:

Optional[QgsMapLayer]

static parameterAsLayerList(definition: QgsProcessingParameterDefinition | None, parameters: Dict[str, Any], context: QgsProcessingContext, flags: QgsProcessing.LayerOptionsFlags | QgsProcessing.LayerOptionsFlag = QgsProcessing.LayerOptionsFlags()) List[QgsMapLayer]

Evaluates the parameter with matching definition to a list of map layers. The flags are used to set options for loading layers (e.g. skip index generation).

Parameters:
Return type:

List[QgsMapLayer]

static parameterAsLayerList(definition: QgsProcessingParameterDefinition | None, value: Any, context: QgsProcessingContext, flags: QgsProcessing.LayerOptionsFlags | QgsProcessing.LayerOptionsFlag = QgsProcessing.LayerOptionsFlags()) List[QgsMapLayer]

Evaluates the parameter with matching definition and value to a list of map layers. The flags are used to set options for loading layers (e.g. skip index generation).

Added in version 3.4.

Parameters:
Return type:

List[QgsMapLayer]

static parameterAsLayout(definition: QgsProcessingParameterDefinition | None, parameters: Dict[str, Any], context: QgsProcessingContext) QgsPrintLayout | None[source]

Evaluates the parameter with matching definition to a print layout.

Warning

This method is not safe to run in a background thread, so it must either be used within a prepareAlgorithm implementation (which runs in the main thread), or the algorithm must return the FlagNoThreading flag.

Added in version 3.8.

Parameters:
Return type:

Optional[QgsPrintLayout]

static parameterAsLayout(definition: QgsProcessingParameterDefinition | None, value: Any, context: QgsProcessingContext) QgsPrintLayout | None[source]

Evaluates the parameter with matching definition and value to a print layout.

Warning

This method is not safe to run in a background thread, so it must either be used within a prepareAlgorithm implementation (which runs in the main thread), or the algorithm must return the FlagNoThreading flag.

Added in version 3.8.

Parameters:
Return type:

Optional[QgsPrintLayout]

static parameterAsLayoutItem(definition: QgsProcessingParameterDefinition | None, parameters: Dict[str, Any], context: QgsProcessingContext, layout: QgsPrintLayout | None) QgsLayoutItem | None[source]

Evaluates the parameter with matching definition to a print layout item, taken from the specified layout.

Warning

This method is not safe to run in a background thread, so it must either be used within a prepareAlgorithm implementation (which runs in the main thread), or the algorithm must return the FlagNoThreading flag.

Added in version 3.8.

Parameters:
Return type:

Optional[QgsLayoutItem]

static parameterAsLayoutItem(definition: QgsProcessingParameterDefinition | None, value: Any, context: QgsProcessingContext, layout: QgsPrintLayout | None) QgsLayoutItem | None[source]

Evaluates the parameter with matching definition and value to a print layout, taken from the specified layout.

Warning

This method is not safe to run in a background thread, so it must either be used within a prepareAlgorithm implementation (which runs in the main thread), or the algorithm must return the FlagNoThreading flag.

Added in version 3.8.

Parameters:
Return type:

Optional[QgsLayoutItem]

static parameterAsMatrix(definition: QgsProcessingParameterDefinition | None, parameters: Dict[str, Any], context: QgsProcessingContext) List[Any][source]

Evaluates the parameter with matching definition to a matrix/table of values. Tables are collapsed to a 1 dimensional list.

Parameters:
Return type:

List[Any]

static parameterAsMatrix(definition: QgsProcessingParameterDefinition | None, value: Any, context: QgsProcessingContext) List[Any][source]

Evaluates the parameter with matching definition and value to a matrix/table of values. Tables are collapsed to a 1 dimensional list.

Added in version 3.4.

Parameters:
Return type:

List[Any]

static parameterAsMeshLayer(definition: QgsProcessingParameterDefinition | None, parameters: Dict[str, Any], context: QgsProcessingContext) QgsMeshLayer | None[source]

Evaluates the parameter with matching definition and value to a mesh layer.

Layers will either be taken from context’s active project, or loaded from external sources and stored temporarily in the context. In either case, callers do not need to handle deletion of the returned layer.

Added in version 3.6.

Parameters:
Return type:

Optional[QgsMeshLayer]

static parameterAsMeshLayer(definition: QgsProcessingParameterDefinition | None, value: Any, context: QgsProcessingContext) QgsMeshLayer | None[source]

Evaluates the parameter with matching definition and value to a mesh layer.

Layers will either be taken from context’s active project, or loaded from external sources and stored temporarily in the context. In either case, callers do not need to handle deletion of the returned layer.

Added in version 3.6.

Parameters:
Return type:

Optional[QgsMeshLayer]

static parameterAsOutputLayer(definition: QgsProcessingParameterDefinition | None, parameters: Dict[str, Any], context: QgsProcessingContext) str[source]

Evaluates the parameter with matching definition to a output layer destination.

Parameters:
Return type:

str

static parameterAsOutputLayer(definition: QgsProcessingParameterDefinition | None, value: Any, context: QgsProcessingContext, testOnly: bool = False) str[source]

Evaluates the parameter with matching definition and value to a output layer destination.

Since QGIS 3.38 the testOnly argument can be set to True to evaluate the parameter to an output layer destination for advance testing only. This prevents default behavior such as output post-processing which would otherwise occur.

Added in version 3.4.

Parameters:
Return type:

str

static parameterAsPoint(definition: QgsProcessingParameterDefinition | None, parameters: Dict[str, Any], context: QgsProcessingContext, crs: QgsCoordinateReferenceSystem = QgsCoordinateReferenceSystem()) QgsPointXY[source]

Evaluates the parameter with matching definition to a point.

If crs is set then the point will be automatically reprojected so that it is in the specified crs.

Parameters:
Return type:

QgsPointXY

static parameterAsPoint(definition: QgsProcessingParameterDefinition | None, value: Any, context: QgsProcessingContext, crs: QgsCoordinateReferenceSystem = QgsCoordinateReferenceSystem()) QgsPointXY[source]

Evaluates the parameter with matching definition and value to a point.

If crs is set then the point will be automatically reprojected so that it is in the specified crs.

Added in version 3.4.

Parameters:
Return type:

QgsPointXY

static parameterAsPointCloudLayer(definition: QgsProcessingParameterDefinition | None, parameters: Dict[str, Any], context: QgsProcessingContext, flags: QgsProcessing.LayerOptionsFlags | QgsProcessing.LayerOptionsFlag = QgsProcessing.LayerOptionsFlags()) QgsPointCloudLayer | None[source]

Evaluates the parameter with matching definition to a point cloud layer. The flags are used to set options for loading layer (e.g. skip index generation).

Layers will either be taken from context’s active project, or loaded from external sources and stored temporarily in the context. In either case, callers do not need to handle deletion of the returned layer.

Added in version 3.22.

Parameters:
Return type:

Optional[QgsPointCloudLayer]

static parameterAsPointCloudLayer(definition: QgsProcessingParameterDefinition | None, value: Any, context: QgsProcessingContext, flags: QgsProcessing.LayerOptionsFlags | QgsProcessing.LayerOptionsFlag = QgsProcessing.LayerOptionsFlags()) QgsPointCloudLayer | None[source]

Evaluates the parameter with matching definition and value to a point cloud layer. The flags are used to set options for loading layer (e.g. skip index generation).

Layers will either be taken from context’s active project, or loaded from external sources and stored temporarily in the context. In either case, callers do not need to handle deletion of the returned layer.

Added in version 3.22.

Parameters:
Return type:

Optional[QgsPointCloudLayer]

static parameterAsPointCrs(definition: QgsProcessingParameterDefinition | None, parameters: Dict[str, Any], context: QgsProcessingContext) QgsCoordinateReferenceSystem[source]

Returns the coordinate reference system associated with an point parameter value.

Parameters:
Return type:

QgsCoordinateReferenceSystem

static parameterAsPointCrs(definition: QgsProcessingParameterDefinition | None, value: Any, context: QgsProcessingContext) QgsCoordinateReferenceSystem[source]

Returns the coordinate reference system associated with an point parameter value.

Added in version 3.8.

Parameters:
Return type:

QgsCoordinateReferenceSystem

static parameterAsRange(definition: QgsProcessingParameterDefinition | None, parameters: Dict[str, Any], context: QgsProcessingContext) List[float]

Evaluates the parameter with matching definition to a range of values.

Parameters:
Return type:

List[float]

static parameterAsRange(definition: QgsProcessingParameterDefinition | None, value: Any, context: QgsProcessingContext) List[float]

Evaluates the parameter with matching definition and value to a range of values.

Added in version 3.4.

Parameters:
Return type:

List[float]

static parameterAsRasterLayer(definition: QgsProcessingParameterDefinition | None, parameters: Dict[str, Any], context: QgsProcessingContext) QgsRasterLayer | None[source]

Evaluates the parameter with matching definition to a raster layer.

Layers will either be taken from context’s active project, or loaded from external sources and stored temporarily in the context. In either case, callers do not need to handle deletion of the returned layer.

Parameters:
Return type:

Optional[QgsRasterLayer]

static parameterAsRasterLayer(definition: QgsProcessingParameterDefinition | None, value: Any, context: QgsProcessingContext) QgsRasterLayer | None[source]

Evaluates the parameter with matching definition and value to a raster layer.

Layers will either be taken from context’s active project, or loaded from external sources and stored temporarily in the context. In either case, callers do not need to handle deletion of the returned layer.

Added in version 3.4.

Parameters:
Return type:

Optional[QgsRasterLayer]

static parameterAsSchema(definition: QgsProcessingParameterDefinition | None, parameters: Dict[str, Any], context: QgsProcessingContext) str[source]

Evaluates the parameter with matching definition to a database schema name.

Added in version 3.14.

Parameters:
Return type:

str

static parameterAsSchema(definition: QgsProcessingParameterDefinition | None, value: Any, context: QgsProcessingContext) str[source]

Evaluates the parameter with matching definition and value to a database schema name.

Added in version 3.14.

Parameters:
Return type:

str

static parameterAsSink(definition: QgsProcessingParameterDefinition | None, parameters: Dict[str, Any], fields: QgsFields, geometryType: Qgis.WkbType, crs: QgsCoordinateReferenceSystem, context: QgsProcessingContext, sinkFlags: QgsFeatureSink.SinkFlags | QgsFeatureSink.SinkFlag = QgsFeatureSink.SinkFlags(), createOptions: Dict[str, Any] = {}, datasourceOptions: Iterable[str | None] = [], layerOptions: Iterable[str | None] = [])[source]

Evaluates the parameter with matching definition to a feature sink.

The fields, geometryType and crs parameters dictate the properties of the resulting feature sink.

Sinks will either be taken from context’s active project, or created from external providers and stored temporarily in the context. The destinationIdentifier argument will be set to a string which can be used to retrieve the layer corresponding to the sink, e.g. via calling QgsProcessingUtils.mapLayerFromString().

The createOptions argument is used to pass on creation options such as layer name.

The datasourceOptions and layerOptions arguments is used to pass on GDAL-specific format driver options.

This function creates a new object and the caller takes responsibility for deleting the returned object.

Parameters:
static parameterAsSink(definition: QgsProcessingParameterDefinition | None, value: Any, fields: QgsFields, geometryType: Qgis.WkbType, crs: QgsCoordinateReferenceSystem, context: QgsProcessingContext, sinkFlags: QgsFeatureSink.SinkFlags | QgsFeatureSink.SinkFlag = QgsFeatureSink.SinkFlags(), createOptions: Dict[str, Any] = {}, datasourceOptions: Iterable[str | None] = [], layerOptions: Iterable[str | None] = [])[source]

Evaluates the parameter with matching definition and value to a feature sink.

The fields, geometryType and crs parameters dictate the properties of the resulting feature sink.

Sinks will either be taken from context’s active project, or created from external providers and stored temporarily in the context. The destinationIdentifier argument will be set to a string which can be used to retrieve the layer corresponding to the sink, e.g. via calling QgsProcessingUtils.mapLayerFromString().

The createOptions argument is used to pass on creation options such as layer name.

The datasourceOptions and layerOptions arguments is used to pass on GDAL-specific format driver options.

This function creates a new object and the caller takes responsibility for deleting the returned object.

Raises:

QgsProcessingException

Added in version 3.4.

Parameters:
static parameterAsSource(definition: QgsProcessingParameterDefinition | None, parameters: Dict[str, Any], context: QgsProcessingContext) QgsProcessingFeatureSource | None[source]

Evaluates the parameter with matching definition to a feature source.

Sources will either be taken from context’s active project, or loaded from external sources and stored temporarily in the context.

This function creates a new object and the caller takes responsibility for deleting the returned object.

Parameters:
Return type:

Optional[QgsProcessingFeatureSource]

static parameterAsSource(definition: QgsProcessingParameterDefinition | None, value: Any, context: QgsProcessingContext) QgsProcessingFeatureSource | None[source]

Evaluates the parameter with matching definition and value to a feature source.

Sources will either be taken from context’s active project, or loaded from external sources and stored temporarily in the context.

This function creates a new object and the caller takes responsibility for deleting the returned object.

Added in version 3.4.

Parameters:
Return type:

Optional[QgsProcessingFeatureSource]

static parameterAsString(definition: QgsProcessingParameterDefinition | None, parameters: Dict[str, Any], context: QgsProcessingContext) str[source]

Evaluates the parameter with matching definition to a static string value.

Parameters:
Return type:

str

static parameterAsString(definition: QgsProcessingParameterDefinition | None, value: Any, context: QgsProcessingContext) str[source]

Evaluates the parameter with matching definition and value to a static string value.

Added in version 3.4.

Parameters:
Return type:

str

static parameterAsStrings(definition: QgsProcessingParameterDefinition | None, parameters: Dict[str, Any], context: QgsProcessingContext) List[str][source]

Evaluates the parameter with matching definition to a list of strings (e.g. field names or point cloud attributes).

Added in version 3.32.

Parameters:
Return type:

List[str]

static parameterAsStrings(definition: QgsProcessingParameterDefinition | None, value: Any, context: QgsProcessingContext) List[str][source]

Evaluates the parameter with matching definition and value to a list of strings (e.g. field names or point cloud attributes).

Added in version 3.32.

Parameters:
Return type:

List[str]

static parameterAsTime(definition: QgsProcessingParameterDefinition | None, parameters: Dict[str, Any], context: QgsProcessingContext) QTime[source]

Evaluates the parameter with matching definition to a static time value.

Added in version 3.14.

Parameters:
Return type:

QTime

static parameterAsTime(definition: QgsProcessingParameterDefinition | None, value: Any, context: QgsProcessingContext) QTime[source]

Evaluates the parameter with matching definition and value to a static time value.

Added in version 3.14.

Parameters:
Return type:

QTime

static parameterAsVectorLayer(definition: QgsProcessingParameterDefinition | None, parameters: Dict[str, Any], context: QgsProcessingContext) QgsVectorLayer | None[source]

Evaluates the parameter with matching definition to a vector layer.

Layers will either be taken from context’s active project, or loaded from external sources and stored temporarily in the context. In either case, callers do not need to handle deletion of the returned layer.

Parameters:
Return type:

Optional[QgsVectorLayer]

static parameterAsVectorLayer(definition: QgsProcessingParameterDefinition | None, value: Any, context: QgsProcessingContext) QgsVectorLayer | None[source]

Evaluates the parameter with matching definition and value to a vector layer.

Layers will either be taken from context’s active project, or loaded from external sources and stored temporarily in the context. In either case, callers do not need to handle deletion of the returned layer.

Added in version 3.4.

Parameters:
Return type:

Optional[QgsVectorLayer]

static parameterFromScriptCode(code: str | None) QgsProcessingParameterDefinition | None[source]

Creates a new QgsProcessingParameterDefinition using the configuration from a supplied script code string. The caller takes responsibility for deleting the returned object.

Parameters:

code (Optional[str])

Return type:

Optional[QgsProcessingParameterDefinition]

static parameterFromVariantMap(map: Dict[str, Any]) QgsProcessingParameterDefinition | None[source]

Creates a new QgsProcessingParameterDefinition using the configuration from a supplied variant map. The caller takes responsibility for deleting the returned object.

Parameters:

map (Dict[str, Any])

Return type:

Optional[QgsProcessingParameterDefinition]