Class: QgsProcessingParameters

class qgis.core.QgsProcessingParameters

Bases: sip.wrapper

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).

New in version 3.0:

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.

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.

descriptionFromName(name: str) str

Creates an autogenerated parameter description from a parameter name.

Parameters:

name (str) –

Return type:

str

isDynamic(parameters: Dict[str, Any], name: str) bool

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) –

  • name (str) –

Return type:

bool

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

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.

New in version 3.22.

parameterAsAnnotationLayer(definition: QgsProcessingParameterDefinition, value: Any, context: QgsProcessingContext) -> QgsAnnotationLayer 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.

New in version 3.22.

Parameters:
Return type:

QgsAnnotationLayer

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

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

parameterAsBool(definition: QgsProcessingParameterDefinition, value: Any, context: QgsProcessingContext) -> bool Evaluates the parameter with matching definition and value to a static boolean value.

New in version 3.4.

Parameters:
Return type:

bool

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

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

New in version 3.8.

parameterAsBoolean(definition: QgsProcessingParameterDefinition, value: Any, context: QgsProcessingContext) -> bool Evaluates the parameter with matching definition and value to a static boolean value.

New in version 3.8.

Parameters:
Return type:

bool

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

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

New in version 3.10.

parameterAsColor(definition: QgsProcessingParameterDefinition, value: Any, context: QgsProcessingContext) -> QColor Returns the color associated with an color parameter value, or an invalid color if the parameter was not set.

New in version 3.10.

Parameters:
Return type:

QColor

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

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

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

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 (QgsProcessingParameterDefinition) – associated parameter definition

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

  • context (QgsProcessingContext) – processing context

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

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

  • feedback (QgsProcessingFeedback = None) – feedback object

Return type:

Tuple[str, str]

Returns:

  • path to source layer, or nearly converted compatible layer

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

New in version 3.10.

parameterAsConnectionName(definition: QgsProcessingParameterDefinition, parameters: Dict[str, Any], context: QgsProcessingContext) str

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

New in version 3.14.

parameterAsConnectionName(definition: QgsProcessingParameterDefinition, value: Any, context: QgsProcessingContext) -> str Evaluates the parameter with matching definition and value to a connection name string.

New in version 3.14.

Parameters:
Return type:

str

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

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

parameterAsCrs(definition: QgsProcessingParameterDefinition, value: Any, context: QgsProcessingContext) -> QgsCoordinateReferenceSystem Evaluates the parameter with matching definition and value to a coordinate reference system.

New in version 3.4.

Parameters:
Return type:

QgsCoordinateReferenceSystem

parameterAsDatabaseTableName(definition: QgsProcessingParameterDefinition, parameters: Dict[str, Any], context: QgsProcessingContext) str

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

New in version 3.14.

parameterAsDatabaseTableName(definition: QgsProcessingParameterDefinition, value: Any, context: QgsProcessingContext) -> str Evaluates the parameter with matching definition and value to a database table name.

New in version 3.14.

Parameters:
Return type:

str

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

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

New in version 3.14.

parameterAsDate(definition: QgsProcessingParameterDefinition, value: Any, context: QgsProcessingContext) -> QDate Evaluates the parameter with matching definition and value to a static date value.

New in version 3.14.

Parameters:
Return type:

QDate

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

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

New in version 3.14.

parameterAsDateTime(definition: QgsProcessingParameterDefinition, value: Any, context: QgsProcessingContext) -> QDateTime Evaluates the parameter with matching definition and value to a static datetime value.

New in version 3.14.

Parameters:
Return type:

QDateTime

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

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

parameterAsDouble(definition: QgsProcessingParameterDefinition, value: Any, context: QgsProcessingContext) -> float Evaluates the parameter with matching definition and value to a static double value.

New in version 3.4.

Parameters:
Return type:

float

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

Evaluates the parameter with matching definition to a enum value.

parameterAsEnum(definition: QgsProcessingParameterDefinition, value: Any, context: QgsProcessingContext) -> int Evaluates the parameter with matching definition and value to a enum value.

New in version 3.4.

Parameters:
Return type:

int

parameterAsEnumString(definition: QgsProcessingParameterDefinition, parameters: Dict[str, Any], context: QgsProcessingContext) str

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

New in version 3.18.

parameterAsEnumString(definition: QgsProcessingParameterDefinition, value: Any, context: QgsProcessingContext) -> str Evaluates the parameter with matching definition and value to a static enum string.

New in version 3.18.

Parameters:
Return type:

str

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

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

New in version 3.18.

parameterAsEnumStrings(definition: QgsProcessingParameterDefinition, value: Any, context: QgsProcessingContext) -> List[str] Evaluates the parameter with matching definition and value to list of static enum strings.

New in version 3.18.

Parameters:
Return type:

List[str]

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

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

parameterAsEnums(definition: QgsProcessingParameterDefinition, value: Any, context: QgsProcessingContext) -> List[int] Evaluates the parameter with matching definition and value to list of enum values.

New in version 3.4.

Parameters:
Return type:

List[int]

parameterAsExpression(definition: QgsProcessingParameterDefinition, parameters: Dict[str, Any], context: QgsProcessingContext) str

Evaluates the parameter with matching definition to an expression.

parameterAsExpression(definition: QgsProcessingParameterDefinition, value: Any, context: QgsProcessingContext) -> str Evaluates the parameter with matching definitionand value to an expression.

New in version 3.4.

Parameters:
Return type:

str

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

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.

parameterAsExtent(definition: QgsProcessingParameterDefinition, value: Any, context: QgsProcessingContext, crs: QgsCoordinateReferenceSystem = QgsCoordinateReferenceSystem()) -> QgsRectangle 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.

New in version 3.4.

Parameters:
Return type:

QgsRectangle

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

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

parameterAsExtentCrs(definition: QgsProcessingParameterDefinition, value: Any, context: QgsProcessingContext) -> QgsCoordinateReferenceSystem Returns the coordinate reference system associated with an extent parameter value.

Parameters:
Return type:

QgsCoordinateReferenceSystem

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

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

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

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

parameterAsFields(definition: QgsProcessingParameterDefinition, value: Any, context: QgsProcessingContext) -> List[str] Evaluates the parameter with matching definition and value to a list of fields.

New in version 3.4.

Parameters:
Return type:

List[str]

parameterAsFile(definition: QgsProcessingParameterDefinition, parameters: Dict[str, Any], context: QgsProcessingContext) str

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

parameterAsFile(definition: QgsProcessingParameterDefinition, value: Any, context: QgsProcessingContext) -> str Evaluates the parameter with matching definition and value to a file/folder name.

New in version 3.4.

Parameters:
Return type:

str

parameterAsFileList(definition: QgsProcessingParameterDefinition, value: Any, context: QgsProcessingContext) List[str]

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

New in version 3.10.

parameterAsFileList(definition: QgsProcessingParameterDefinition, parameters: Dict[str, Any], context: QgsProcessingContext) -> List[str] Evaluates the parameter with matching definition to a list of files (for QgsProcessingParameterMultipleLayers in QgsProcessing:TypeFile mode).

New in version 3.10.

Parameters:
Return type:

List[str]

parameterAsFileOutput(definition: QgsProcessingParameterDefinition, parameters: Dict[str, Any], context: QgsProcessingContext) str

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

parameterAsFileOutput(definition: QgsProcessingParameterDefinition, value: Any, context: QgsProcessingContext) -> str Evaluates the parameter with matching definition and value to a file based output destination.

New in version 3.4.

Parameters:
Return type:

str

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

Evaluates the parameter with matching definition to a geometry.

New in version 3.16.

parameterAsGeometry(definition: QgsProcessingParameterDefinition, value: Any, context: QgsProcessingContext, crs: QgsCoordinateReferenceSystem = QgsCoordinateReferenceSystem()) -> QgsGeometry Evaluates the parameter with matching definition and value to a geometry.

New in version 3.16.

Parameters:
Return type:

QgsGeometry

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

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

New in version 3.16.

parameterAsGeometryCrs(definition: QgsProcessingParameterDefinition, value: Any, context: QgsProcessingContext) -> QgsCoordinateReferenceSystem Returns the coordinate reference system associated with an point parameter value.

New in version 3.16.

Parameters:
Return type:

QgsCoordinateReferenceSystem

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

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

parameterAsInt(definition: QgsProcessingParameterDefinition, value: Any, context: QgsProcessingContext) -> int Evaluates the parameter with matching definition and value to a static integer value.

New in version 3.4.

Parameters:
Return type:

int

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

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

New in version 3.4.

parameterAsInts(definition: QgsProcessingParameterDefinition, value: Any, context: QgsProcessingContext) -> List[int] Evaluates the parameter with matching definition and value to a list of integer values.

New in version 3.4.

Parameters:
Return type:

List[int]

parameterAsLayer(definition: QgsProcessingParameterDefinition, parameters: Dict[str, Any], context: QgsProcessingContext, layerHint: QgsProcessingUtils.LayerHint = QgsProcessingUtils.LayerHint.UnknownType) QgsMapLayer

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.

parameterAsLayer(definition: QgsProcessingParameterDefinition, value: Any, context: QgsProcessingContext, layerHint: QgsProcessingUtils.LayerHint = QgsProcessingUtils.LayerHint.UnknownType) -> QgsMapLayer 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.

New in version 3.4.

Parameters:
Return type:

QgsMapLayer

parameterAsLayerList(definition: QgsProcessingParameterDefinition, parameters: Dict[str, Any], context: QgsProcessingContext) List[QgsMapLayer]

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

parameterAsLayerList(definition: QgsProcessingParameterDefinition, value: Any, context: QgsProcessingContext) -> List[QgsMapLayer] Evaluates the parameter with matching definition and value to a list of map layers.

New in version 3.4.

Parameters:
Return type:

List[QgsMapLayer]

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

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.

New in version 3.8.

parameterAsLayout(definition: QgsProcessingParameterDefinition, value: Any, context: QgsProcessingContext) -> QgsPrintLayout 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.

New in version 3.8.

Parameters:
Return type:

QgsPrintLayout

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

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.

New in version 3.8.

parameterAsLayoutItem(definition: QgsProcessingParameterDefinition, value: Any, context: QgsProcessingContext, layout: QgsPrintLayout) -> QgsLayoutItem 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.

New in version 3.8.

Parameters:
Return type:

QgsLayoutItem

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

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

parameterAsMatrix(definition: QgsProcessingParameterDefinition, value: Any, context: QgsProcessingContext) -> List[Any] Evaluates the parameter with matching definition and value to a matrix/table of values. Tables are collapsed to a 1 dimensional list.

New in version 3.4.

Parameters:
Return type:

List[Any]

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

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.

New in version 3.6.

parameterAsMeshLayer(definition: QgsProcessingParameterDefinition, value: Any, context: QgsProcessingContext) -> QgsMeshLayer 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.

New in version 3.6.

Parameters:
Return type:

QgsMeshLayer

parameterAsOutputLayer(definition: QgsProcessingParameterDefinition, parameters: Dict[str, Any], context: QgsProcessingContext) str

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

parameterAsOutputLayer(definition: QgsProcessingParameterDefinition, value: Any, context: QgsProcessingContext) -> str Evaluates the parameter with matching definition and value to a output layer destination.

New in version 3.4.

Parameters:
Return type:

str

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

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.

parameterAsPoint(definition: QgsProcessingParameterDefinition, value: Any, context: QgsProcessingContext, crs: QgsCoordinateReferenceSystem = QgsCoordinateReferenceSystem()) -> QgsPointXY 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.

New in version 3.4.

Parameters:
Return type:

QgsPointXY

parameterAsPointCloudLayer(definition: QgsProcessingParameterDefinition, parameters: Dict[str, Any], context: QgsProcessingContext) QgsPointCloudLayer

Evaluates the parameter with matching definition to a point cloud 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.

New in version 3.22.

parameterAsPointCloudLayer(definition: QgsProcessingParameterDefinition, value: Any, context: QgsProcessingContext) -> QgsPointCloudLayer Evaluates the parameter with matching definition and value to a point cloud 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.

New in version 3.22.

Parameters:
Return type:

QgsPointCloudLayer

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

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

parameterAsPointCrs(definition: QgsProcessingParameterDefinition, value: Any, context: QgsProcessingContext) -> QgsCoordinateReferenceSystem Returns the coordinate reference system associated with an point parameter value.

New in version 3.8.

Parameters:
Return type:

QgsCoordinateReferenceSystem

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

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

parameterAsRange(definition: QgsProcessingParameterDefinition, value: Any, context: QgsProcessingContext) -> List[float] Evaluates the parameter with matching definition and value to a range of values.

New in version 3.4.

Parameters:
Return type:

List[float]

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

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.

parameterAsRasterLayer(definition: QgsProcessingParameterDefinition, value: Any, context: QgsProcessingContext) -> QgsRasterLayer 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.

New in version 3.4.

Parameters:
Return type:

QgsRasterLayer

parameterAsSchema(definition: QgsProcessingParameterDefinition, parameters: Dict[str, Any], context: QgsProcessingContext) str

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

New in version 3.14.

parameterAsSchema(definition: QgsProcessingParameterDefinition, value: Any, context: QgsProcessingContext) -> str Evaluates the parameter with matching definition and value to a database schema name.

New in version 3.14.

Parameters:
Return type:

str

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

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.

parameterAsSink(definition: QgsProcessingParameterDefinition, value: Any, fields: QgsFields, geometryType: QgsWkbTypes.Type, crs: QgsCoordinateReferenceSystem, context: QgsProcessingContext, sinkFlags: Union[QgsFeatureSink.SinkFlags, QgsFeatureSink.SinkFlag] = QgsFeatureSink.SinkFlags(), createOptions: Dict[str, Any] = {}, datasourceOptions: Iterable[str] = [], layerOptions: Iterable[str] = []) -> Tuple[QgsFeatureSink, str] 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

New in version 3.4.

Parameters:
Return type:

Tuple[QgsFeatureSink, str]

parameterAsSource(definition: QgsProcessingParameterDefinition, parameters: Dict[str, Any], context: QgsProcessingContext) QgsProcessingFeatureSource

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.

parameterAsSource(definition: QgsProcessingParameterDefinition, value: Any, context: QgsProcessingContext) -> QgsProcessingFeatureSource 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.

New in version 3.4.

Parameters:
Return type:

QgsProcessingFeatureSource

parameterAsString(definition: QgsProcessingParameterDefinition, parameters: Dict[str, Any], context: QgsProcessingContext) str

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

parameterAsString(definition: QgsProcessingParameterDefinition, value: Any, context: QgsProcessingContext) -> str Evaluates the parameter with matching definition and value to a static string value.

New in version 3.4.

Parameters:
Return type:

str

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

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

New in version 3.14.

parameterAsTime(definition: QgsProcessingParameterDefinition, value: Any, context: QgsProcessingContext) -> QTime Evaluates the parameter with matching definition and value to a static time value.

New in version 3.14.

Parameters:
Return type:

QTime

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

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.

parameterAsVectorLayer(definition: QgsProcessingParameterDefinition, value: Any, context: QgsProcessingContext) -> QgsVectorLayer 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.

New in version 3.4.

Parameters:
Return type:

QgsVectorLayer

parameterFromScriptCode(code: str) QgsProcessingParameterDefinition

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

Parameters:

code (str) –

Return type:

QgsProcessingParameterDefinition

parameterFromVariantMap(map: Dict[str, Any]) QgsProcessingParameterDefinition

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) –

Return type:

QgsProcessingParameterDefinition