重要

Translation is a community effort you can join. This page is currently translated at 49.33%.

28.1.9. Modeler tools

警告

These tools are only available in the model designer. They are not available in the Processing Toolbox.

28.1.9.1. Calculate expression

NEW in 3.34

It calculates the result of a QGIS expression and eliminates the need to use the same expression multiple times throughout a model when the same result is required more than once. Additionally, it enables use cases that would otherwise not be possible. For instance, you can generate a timestamp value once and use it multiple times within the model, if the timestamp were recalculated every time, the values would vary during the model's runtime.

参数

标注

名称

类型

描述

Input

INPUT

[expression]

Expression to calculate

输出

标注

名称

类型

描述

Value

OUTPUT

[Result Value]

Calculated result value, the data type of the output will vary based on the specific expression used in the algorithm.

Python代码

Algorithm ID: native:calculateexpression

import processing
processing.run("algorithm_id", {parameter_dictionary})

当你在数据处理工具箱某个算法前悬停时,算法 id 将会展现。*参数字*将会提供参数的名称与数值。参考详见`数据处理_控制台`以获取如何从Python控制台中运行数据处理算法。

28.1.9.2. Conditional branch

Adds a conditional branch into a model, allowing parts of the model to be executed based on the result of an expression evaluation. Mostly by using tool dependencies to control the flow of a model.

参数

标注

名称

类型

描述

字段

BRANCH

[string]

Name of the condition

字段

CONDITION

[expression]

Expression to evaluate

输出

None.

Python代码

Algorithm ID: native:condition

import processing
processing.run("algorithm_id", {parameter_dictionary})

当你在数据处理工具箱某个算法前悬停时,算法 id 将会展现。*参数字*将会提供参数的名称与数值。参考详见`数据处理_控制台`以获取如何从Python控制台中运行数据处理算法。

28.1.9.3. Create directory

Creates a new directory on a file system. Directories will be created recursively, creating all required parent directories in order to construct the full specified directory path. No errors will be raised if the directory already exists.

参数

标注

名称

类型

描述

Directory path

PATH

[string]

Folder path to create

输出

标注

名称

类型

描述

Output

OUTPUT

[folder]

Created folder

Python代码

Algorithm ID: native:createdirectory

import processing
processing.run("algorithm_id", {parameter_dictionary})

当你在数据处理工具箱某个算法前悬停时,算法 id 将会展现。*参数字*将会提供参数的名称与数值。参考详见`数据处理_控制台`以获取如何从Python控制台中运行数据处理算法。

28.1.9.4. Feature filter

Filters features from the input layer and redirects them to one or several outputs. If you do not know about any attribute names that are common to all possible input layers, filtering is only possible on the feature geometry and general record mechanisms, such as $id and uuid.

参数

标注

名称

类型

描述

输入图层

INPUT

[vector: any]

The input layer.

Outputs and filters

(one or more)

OUTPUT_<name of the filter>

[same as input]

The output layers with filters (as many as there are filters).

输出

标注

名称

类型

描述

Output

(one or more)

native:filter_1:OUTPUT_<name of filter>

[same as input]

The output layers with filtered features (as many as there are filters).

Python代码

Algorithm ID: native:filter

import processing
processing.run("algorithm_id", {parameter_dictionary})

当你在数据处理工具箱某个算法前悬停时,算法 id 将会展现。*参数字*将会提供参数的名称与数值。参考详见`数据处理_控制台`以获取如何从Python控制台中运行数据处理算法。

28.1.9.5. Filter layers by type

Filters layers by their type. Incoming layers will be directed to different outputs based on whether they are a vector or raster layer.

参数

标注

名称

类型

描述

输入图层

INPUT

[layer]

Generic Map Layer

输出

标注

名称

类型

描述

Vector features

可选

VECTOR

[vector]

A Vector Layer of the input, if compatible

Raster layer

可选

RASTER

[栅格]

A Raster Layer of the input, if compatible

Python代码

Algorithm ID: native:filterlayersbytype

import processing
processing.run("algorithm_id", {parameter_dictionary})

当你在数据处理工具箱某个算法前悬停时,算法 id 将会展现。*参数字*将会提供参数的名称与数值。参考详见`数据处理_控制台`以获取如何从Python控制台中运行数据处理算法。

28.1.9.6. Load layer into project

Loads a layer to the current project.

参数

标注

名称

类型

描述

Layer

INPUT

[layer]

Layer to load in the legend

Loaded layer name

NAME

[string]

Name of the loaded layer

输出

标注

名称

类型

描述

Layer

OUTPUT

[same as input]

The (renamed) loaded layer

Python代码

Algorithm ID: native:loadlayer

import processing
processing.run("algorithm_id", {parameter_dictionary})

当你在数据处理工具箱某个算法前悬停时,算法 id 将会展现。*参数字*将会提供参数的名称与数值。参考详见`数据处理_控制台`以获取如何从Python控制台中运行数据处理算法。

28.1.9.7. Raise exception

Raises an exception and cancels a model's execution. The exception message can be customized, and optionally an expression based condition can be specified. If an expression condition is used, then the exception will only be raised if the expression result is true. A false result indicates that no exception will be raised, and the model execution can continue uninterrupted.

参数

标注

名称

类型

描述

Message

MESSAGE

[string]

Message to display

Condition

可选

CONDITION

[expression]

Expression to evaluate if true

输出

A message in the log panel.

Python代码

Algorithm ID: native:raiseexception

import processing
processing.run("algorithm_id", {parameter_dictionary})

当你在数据处理工具箱某个算法前悬停时,算法 id 将会展现。*参数字*将会提供参数的名称与数值。参考详见`数据处理_控制台`以获取如何从Python控制台中运行数据处理算法。

28.1.9.8. Raise message

Raises an information message in the log. The message can be customized, and optionally an expression based condition can be specified. If an expression condition is used, then the message will only be logged if the expression result is true. A false result indicates that no message will be logged.

参数

标注

名称

类型

描述

Information message

MESSAGE

[string]

Message to display

Condition

可选

CONDITION

[expression]

Expression to evaluate if true

输出

A message in the log panel.

Python代码

Algorithm ID: native:raisemessage

import processing
processing.run("algorithm_id", {parameter_dictionary})

当你在数据处理工具箱某个算法前悬停时,算法 id 将会展现。*参数字*将会提供参数的名称与数值。参考详见`数据处理_控制台`以获取如何从Python控制台中运行数据处理算法。

28.1.9.9. Raise warning

Raises a warning message in the log. The warning message can be customized, and optionally an expression based condition can be specified. If an expression condition is used, then the warning will only be logged if the expression result is true. A false result indicates that no warning will be logged.

参数

标注

名称

类型

描述

Message

MESSAGE

[string]

Message to display

Condition

可选

CONDITION

[expression]

Expression to evaluate if true

输出

A message in the log panel.

Python代码

Algorithm ID: native:raisewarning

import processing
processing.run("algorithm_id", {parameter_dictionary})

当你在数据处理工具箱某个算法前悬停时,算法 id 将会展现。*参数字*将会提供参数的名称与数值。参考详见`数据处理_控制台`以获取如何从Python控制台中运行数据处理算法。

28.1.9.10. Rename layer

Renames a layer.

参数

标注

名称

类型

描述

Layer

INPUT

[layer]

Layer to rename

New name

NAME

[string]

The new name of the layer

输出

标注

名称

类型

描述

Layer

OUTPUT

[same as input]

The (renamed) output layer

Python代码

Algorithm ID: native:renamelayer

import processing
processing.run("algorithm_id", {parameter_dictionary})

当你在数据处理工具箱某个算法前悬停时,算法 id 将会展现。*参数字*将会提供参数的名称与数值。参考详见`数据处理_控制台`以获取如何从Python控制台中运行数据处理算法。

28.1.9.11. Save log to file

Saves the model's execution log to a file. Optionally, the log can be saved in a HTML formatted version.

参数

标注

名称

类型

描述

Use HTML

USE_HTML

[Boolean]

Default: False

Use HTML formatting

输出

标注

名称

类型

描述

File

OUTPUT

[string]

Destination of the log

Python代码

Algorithm ID: native:savelog

import processing
processing.run("algorithm_id", {parameter_dictionary})

当你在数据处理工具箱某个算法前悬停时,算法 id 将会展现。*参数字*将会提供参数的名称与数值。参考详见`数据处理_控制台`以获取如何从Python控制台中运行数据处理算法。

28.1.9.12. Set project variable

Sets an expression variable for the current project.

参数

标注

名称

类型

描述

Variable name

NAME

[string]

Name of the variable

Variable value

VALUE

[string]

Value to be stored

输出

None.

Python代码

Algorithm ID: native:setprojectvariable

import processing
processing.run("algorithm_id", {parameter_dictionary})

当你在数据处理工具箱某个算法前悬停时,算法 id 将会展现。*参数字*将会提供参数的名称与数值。参考详见`数据处理_控制台`以获取如何从Python控制台中运行数据处理算法。

28.1.9.13. String concatenation

Concatenates two strings into a single one in the Processing Modeler.

参数

标注

名称

类型

描述

Input 1

INPUT_1

[string]

First string

Input 2

INPUT_2

[string]

Second string

输出

标注

名称

类型

描述

Concatenation

CONCATENATION

[string]

The concatenated string

Python代码

Algorithm ID: native:stringconcatenation

import processing
processing.run("algorithm_id", {parameter_dictionary})

当你在数据处理工具箱某个算法前悬停时,算法 id 将会展现。*参数字*将会提供参数的名称与数值。参考详见`数据处理_控制台`以获取如何从Python控制台中运行数据处理算法。

28.1.9.14. Variable distance buffer

警告

This algorithm is deprecated and can be removed anytime. Prefer using Buffer algorithm instead.

Computes a buffer area for all the features in an input layer.

The size of the buffer for a given feature is defined by an attribute, so it allows different features to have different buffer sizes.

参见

Buffer

参数

标注

名称

类型

描述

输入图层

INPUT

[vector: any]

Input vector layer

Distance field

DISTANCE

[tablefield: numeric]

Attribute for the distance radius of the buffer

Segments

SEGMENTS

[数字]

Default: 5

Controls the number of line segments to use to approximate a quarter circle when creating rounded offsets.

Dissolve result

DISSOLVE

[boolean]

Default: False

Choose to dissolve the final buffer, resulting in a single feature covering all input features.

../../../../_images/buffer_dissolve1.png

图 28.8 Normal and dissolved buffer

End cap style

END_CAP_STYLE

[enumeration]

Default: Round

Controls how line endings are handled in the buffer.

../../../../_images/buffer_cap_style.png

图 28.9 Round, flat and square cap styles

Join style

JOIN_STYLE

[enumeration]

Default: Round

Specifies whether round, miter or beveled joins should be used when offsetting corners in a line.

Miter limit

MITER_LIMIT

[数字]

Default: 2.0

Only applicable for mitered join styles, and controls the maximum distance from the offset curve to use when creating a mitered join.

输出

标注

名称

类型

描述

Buffer

OUTPUT

[vector: polygon]

Buffer polygon vector layer.

Python代码

Algorithm ID: qgis:variabledistancebuffer

import processing
processing.run("algorithm_id", {parameter_dictionary})

当你在数据处理工具箱某个算法前悬停时,算法 id 将会展现。*参数字*将会提供参数的名称与数值。参考详见`数据处理_控制台`以获取如何从Python控制台中运行数据处理算法。