@dsh-gis/dsh-opengis-skill 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.editorconfig +19 -0
- package/CHANGELOG.md +96 -0
- package/LICENSE +21 -21
- package/README.md +91 -30
- package/THIRD_PARTY_NOTICES.md +37 -10
- package/assets/gdal/reference/raster-tools.md +538 -538
- package/assets/gdal/reference/vector-tools.md +149 -149
- package/assets/gdal-api/reference/raster-api.md +424 -424
- package/assets/gdal-api/reference/vector-api.md +724 -724
- package/assets/geometry-api-net/reference/geometry-types.md +243 -243
- package/assets/geopandas/reference/core-api.md +221 -221
- package/assets/geotools/reference/raster-rendering.md +108 -108
- package/assets/geotools/reference/vector-io.md +149 -149
- package/assets/jts/reference/geometry-operations.md +303 -303
- package/assets/mapsui/SKILL.md +283 -283
- package/assets/opengis-all/reference/data-stages.md +608 -608
- package/assets/opengis-all/reference/workflow-cheatsheets.md +324 -324
- package/assets/opengis-utils-for-java/reference/common-tasks.md +384 -384
- package/assets/opengis-utils-for-net/reference/code-patterns.md +124 -124
- package/assets/opengis-utils-for-net/reference/util-classes.md +291 -291
- package/assets/pyqgis/reference/processing-rendering.md +292 -292
- package/assets/pyqgis/reference/vector-raster-layers.md +318 -318
- package/assets/qgis-process/SKILL.md +414 -414
- package/assets/qgis-process/reference/algorithm-cheatsheet.md +194 -194
- package/assets/shapely/reference/operations-reference.md +199 -199
- package/cordis.patch.yml +6 -3
- package/lib/catalog.d.ts +50 -0
- package/lib/catalog.js +238 -0
- package/lib/index.d.ts +47 -6
- package/lib/index.js +32 -44
- package/lib/markdown-links.d.ts +11 -0
- package/lib/markdown-links.js +103 -0
- package/lib/skill-file.js +104 -17
- package/locale/en.json +1 -1
- package/locale/zh.json +1 -1
- package/package.json +11 -5
- package/upstream.json +64 -2
|
@@ -1,414 +1,414 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: qgis-process
|
|
3
|
-
description: "Use when running QGIS geoprocessing tools headless from command line or CI/CD — buffer, clip, reproject, raster analysis without GUI. QGIS Processing: batch spatial analysis via qgis_process CLI."
|
|
4
|
-
tags:
|
|
5
|
-
- cli
|
|
6
|
-
- qgis
|
|
7
|
-
- processing
|
|
8
|
-
- raster
|
|
9
|
-
- automation
|
|
10
|
-
- batch
|
|
11
|
-
- ci-cd
|
|
12
|
-
- json
|
|
13
|
-
- workflow
|
|
14
|
-
- shell
|
|
15
|
-
---
|
|
16
|
-
|
|
17
|
-
> **项目地址:** <https://github.com/qgis/QGIS>
|
|
18
|
-
>
|
|
19
|
-
> **文档地址:** <https://github.com/qgis/QGIS-Documentation>
|
|
20
|
-
>
|
|
21
|
-
> **在线文档:** <https://docs.qgis.org/4.2/en/docs/user_manual/processing/standalone.html>
|
|
22
|
-
>
|
|
23
|
-
> **最新版本:** QGIS 4.2.3;3.44 LTR 最新 3.44.15(截至2026-10,GitHub Releases;`qgis_process` 自 QGIS 3.16 起可用)
|
|
24
|
-
>
|
|
25
|
-
> **许可证:** GPL-2.0+
|
|
26
|
-
|
|
27
|
-
## 概述
|
|
28
|
-
|
|
29
|
-
`qgis_process` 是 QGIS 自带的命令行工具(QGIS Processing Executor),允许在**不启动 QGIS 桌面应用**的情况下,直接从命令行运行 Processing 算法和模型(内置算法或由插件提供)。它适用于服务器端批量处理、CI/CD 自动化流水线、脚本化 GIS 工作流等场景。
|
|
30
|
-
|
|
31
|
-
源码位置:`src/process/` 目录下的 `main.cpp`、`qgsprocess.cpp`、`qgsprocess.h`。
|
|
32
|
-
|
|
33
|
-
---
|
|
34
|
-
|
|
35
|
-
## 环境准备
|
|
36
|
-
|
|
37
|
-
### 前置条件
|
|
38
|
-
|
|
39
|
-
- 安装 QGIS 3.16+(`qgis_process` 从 QGIS 3.16 开始可用)
|
|
40
|
-
- 确保 `qgis_process` 可执行文件在 `PATH` 中
|
|
41
|
-
|
|
42
|
-
### 安装方式
|
|
43
|
-
|
|
44
|
-
```bash
|
|
45
|
-
# Ubuntu/Debian
|
|
46
|
-
sudo apt install qgis
|
|
47
|
-
|
|
48
|
-
# Conda(跨平台)
|
|
49
|
-
conda install -c conda-forge qgis
|
|
50
|
-
|
|
51
|
-
# Docker(官方镜像,含 qgis_process;stable=4.2、ltr=3.44)
|
|
52
|
-
docker run --rm -v "$PWD:/data" qgis/qgis:ltr qgis_process --version
|
|
53
|
-
|
|
54
|
-
# Windows:通过 OSGeo4W 安装器安装 QGIS,随后在 "OSGeo4W Shell" 中运行 qgis_process
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
> **提示:** Windows 下手动运行的场景,将 QGIS 安装目录的 `bin`(如 `C:\Program Files\QGIS 3.44\bin` 或 `C:\OSGeo4W\bin`)加入 `PATH`。
|
|
58
|
-
|
|
59
|
-
### 无窗口系统(Headless 服务器)
|
|
60
|
-
|
|
61
|
-
在没有窗口管理器的系统上运行前,需设置环境变量:
|
|
62
|
-
|
|
63
|
-
```bash
|
|
64
|
-
export QT_QPA_PLATFORM=offscreen
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
### 验证安装
|
|
68
|
-
|
|
69
|
-
```bash
|
|
70
|
-
qgis_process --version
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
---
|
|
74
|
-
|
|
75
|
-
## 命令行语法
|
|
76
|
-
|
|
77
|
-
```text
|
|
78
|
-
qgis_process [--help] [--version] [--json] [--verbose] [--no-python] [--skip-loading-plugins] [command] [algorithm id | model path | script path] [parameters]
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
### 全局选项
|
|
82
|
-
|
|
83
|
-
| 选项 | 说明 |
|
|
84
|
-
|------|------|
|
|
85
|
-
| `--help` 或 `-h` | 输出帮助信息 |
|
|
86
|
-
| `--version` 或 `-v` | 输出 QGIS Process 相关的所有版本信息 |
|
|
87
|
-
| `--json` | 以 JSON 格式输出结果(AI/脚本友好) |
|
|
88
|
-
| `--verbose` | 输出详细日志 |
|
|
89
|
-
| `--no-python` | 禁用 Python 支持(启动更快) |
|
|
90
|
-
| `--skip-loading-plugins` | 跳过加载已启用的插件(启动更快) |
|
|
91
|
-
|
|
92
|
-
### 可用命令
|
|
93
|
-
|
|
94
|
-
| 命令 | 说明 |
|
|
95
|
-
|------|------|
|
|
96
|
-
| `plugins` | 列出可用和已激活的插件 |
|
|
97
|
-
| `plugins enable <name>` | 启用已安装的插件 |
|
|
98
|
-
| `plugins disable <name>` | 禁用已安装的插件 |
|
|
99
|
-
| `list` | 列出所有可用的 Processing 算法 |
|
|
100
|
-
| `help <algorithm_id>` | 显示指定算法的帮助信息 |
|
|
101
|
-
| `run <algorithm_id> [-- PARAM=VALUE ...]` | 运行指定算法 |
|
|
102
|
-
|
|
103
|
-
> **注意:** 只有在 `metadata.txt` 中声明了 `hasProcessingProvider=yes` 的已安装插件才能被 `qgis_process` 识别和加载。
|
|
104
|
-
|
|
105
|
-
---
|
|
106
|
-
|
|
107
|
-
## 核心用法
|
|
108
|
-
|
|
109
|
-
### 1. 列出所有算法
|
|
110
|
-
|
|
111
|
-
```bash
|
|
112
|
-
qgis_process list
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
输出所有已注册 Provider 及其提供的算法 ID。
|
|
116
|
-
|
|
117
|
-
### 2. 查看算法帮助
|
|
118
|
-
|
|
119
|
-
```bash
|
|
120
|
-
qgis_process help qgis:regularpoints
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
输出算法的描述、参数列表(名称、类型、默认值、是否可选)和输出定义。
|
|
124
|
-
|
|
125
|
-
#### JSON 格式帮助(推荐 AI 使用)
|
|
126
|
-
|
|
127
|
-
```bash
|
|
128
|
-
qgis_process help native:buffer --json
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
JSON 输出结构:
|
|
132
|
-
|
|
133
|
-
```json
|
|
134
|
-
{
|
|
135
|
-
"qgis_version": "...",
|
|
136
|
-
"algorithm_details": {
|
|
137
|
-
"id": "native:buffer",
|
|
138
|
-
"name": "Buffer",
|
|
139
|
-
"tags": ["..."]
|
|
140
|
-
},
|
|
141
|
-
"provider_details": {
|
|
142
|
-
"id": "native",
|
|
143
|
-
"name": "QGIS (native c++)"
|
|
144
|
-
},
|
|
145
|
-
"parameters": {
|
|
146
|
-
"INPUT": {
|
|
147
|
-
"name": "INPUT",
|
|
148
|
-
"description": "Input layer",
|
|
149
|
-
"type": {
|
|
150
|
-
"id": "source",
|
|
151
|
-
"name": "Vector Features",
|
|
152
|
-
"acceptable_values": ["Path to a vector layer"]
|
|
153
|
-
},
|
|
154
|
-
"optional": false,
|
|
155
|
-
"default_value": null
|
|
156
|
-
},
|
|
157
|
-
"DISTANCE": {
|
|
158
|
-
"name": "DISTANCE",
|
|
159
|
-
"description": "Distance",
|
|
160
|
-
"type": {
|
|
161
|
-
"id": "distance",
|
|
162
|
-
"name": "Distance"
|
|
163
|
-
},
|
|
164
|
-
"optional": false,
|
|
165
|
-
"default_value": 10
|
|
166
|
-
},
|
|
167
|
-
"OUTPUT": {
|
|
168
|
-
"name": "OUTPUT",
|
|
169
|
-
"description": "Buffered",
|
|
170
|
-
"type": {
|
|
171
|
-
"id": "sink",
|
|
172
|
-
"name": "Vector Layer Destination"
|
|
173
|
-
},
|
|
174
|
-
"is_destination": true,
|
|
175
|
-
"optional": false
|
|
176
|
-
}
|
|
177
|
-
},
|
|
178
|
-
"outputs": {
|
|
179
|
-
"OUTPUT": {
|
|
180
|
-
"description": "Buffered",
|
|
181
|
-
"type": "outputVector"
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
```
|
|
186
|
-
|
|
187
|
-
### 3. 运行算法
|
|
188
|
-
|
|
189
|
-
#### 基本语法
|
|
190
|
-
|
|
191
|
-
```bash
|
|
192
|
-
qgis_process run <algorithm_id> -- PARAM1=VALUE1 PARAM2=VALUE2 ...
|
|
193
|
-
```
|
|
194
|
-
|
|
195
|
-
#### 示例:缓冲区分析
|
|
196
|
-
|
|
197
|
-
```bash
|
|
198
|
-
qgis_process run native:buffer -- INPUT=source.shp DISTANCE=2 OUTPUT=buffered.shp
|
|
199
|
-
```
|
|
200
|
-
|
|
201
|
-
#### 示例:合并图层(多值参数)
|
|
202
|
-
|
|
203
|
-
同一参数多次指定即可传入列表值:
|
|
204
|
-
|
|
205
|
-
```bash
|
|
206
|
-
qgis_process run native:mergevectorlayers -- LAYERS=input1.shp LAYERS=input2.shp OUTPUT=merged.shp
|
|
207
|
-
```
|
|
208
|
-
|
|
209
|
-
#### `run` 命令附加选项
|
|
210
|
-
|
|
211
|
-
| 选项 | 说明 |
|
|
212
|
-
|------|------|
|
|
213
|
-
| `--json` | 以 JSON 格式输出执行结果 |
|
|
214
|
-
| `--ellipsoid=<name>` | 指定椭球体,用于距离和面积计算 |
|
|
215
|
-
| `--distance_units=<unit>` | 指定距离单位 |
|
|
216
|
-
| `--area_units=<unit>` | 指定面积单位 |
|
|
217
|
-
| `--project_path=<path>` | 加载已有 QGIS 项目文件供算法执行时使用 |
|
|
218
|
-
|
|
219
|
-
#### JSON 格式运行结果
|
|
220
|
-
|
|
221
|
-
```bash
|
|
222
|
-
qgis_process run native:buffer --json -- INPUT=source.shp DISTANCE=2 OUTPUT=buffered.shp
|
|
223
|
-
```
|
|
224
|
-
|
|
225
|
-
JSON 输出结构:
|
|
226
|
-
|
|
227
|
-
```json
|
|
228
|
-
{
|
|
229
|
-
"qgis_version": "...",
|
|
230
|
-
"algorithm_details": { "id": "native:buffer" },
|
|
231
|
-
"inputs": {
|
|
232
|
-
"INPUT": "source.shp",
|
|
233
|
-
"DISTANCE": "2",
|
|
234
|
-
"OUTPUT": "buffered.shp"
|
|
235
|
-
},
|
|
236
|
-
"results": {
|
|
237
|
-
"OUTPUT": "/full/path/to/buffered.shp"
|
|
238
|
-
},
|
|
239
|
-
"log": ["..."]
|
|
240
|
-
}
|
|
241
|
-
```
|
|
242
|
-
|
|
243
|
-
### 4. 通过 STDIN 传入 JSON 参数(复杂参数)
|
|
244
|
-
|
|
245
|
-
当参数本身是复杂对象(如字典类型)时,可通过 STDIN 传入 JSON:
|
|
246
|
-
|
|
247
|
-
```bash
|
|
248
|
-
qgis_process run <algorithm_id> -
|
|
249
|
-
```
|
|
250
|
-
|
|
251
|
-
末尾的 `-` 表示从 STDIN 读取参数。JSON 必须包含 `"inputs"` 键:
|
|
252
|
-
|
|
253
|
-
```bash
|
|
254
|
-
echo '{"inputs": {"INPUT": "my_shape.shp", "DISTANCE": 5}}' | qgis_process run native:buffer -
|
|
255
|
-
```
|
|
256
|
-
|
|
257
|
-
完整 JSON 结构(含可选配置):
|
|
258
|
-
|
|
259
|
-
```json
|
|
260
|
-
{
|
|
261
|
-
"ellipsoid": "EPSG:7019",
|
|
262
|
-
"distance_units": "feet",
|
|
263
|
-
"area_units": "ha",
|
|
264
|
-
"project_path": "/path/to/project.qgs",
|
|
265
|
-
"inputs": {
|
|
266
|
-
"INPUT": "my_shape.shp",
|
|
267
|
-
"DISTANCE": 5,
|
|
268
|
-
"SEGMENTS": 8,
|
|
269
|
-
"OUTPUT": "output.shp"
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
```
|
|
273
|
-
|
|
274
|
-
> **注意:** 通过 STDIN 传入 JSON 时,输出自动使用 JSON 格式。
|
|
275
|
-
|
|
276
|
-
### 5. 插件管理
|
|
277
|
-
|
|
278
|
-
```bash
|
|
279
|
-
# 列出插件
|
|
280
|
-
qgis_process plugins
|
|
281
|
-
|
|
282
|
-
# 启用插件
|
|
283
|
-
qgis_process plugins enable cartography_tools
|
|
284
|
-
|
|
285
|
-
# 禁用插件
|
|
286
|
-
qgis_process plugins disable cartography_tools
|
|
287
|
-
```
|
|
288
|
-
|
|
289
|
-
### 6. 运行模型文件
|
|
290
|
-
|
|
291
|
-
```bash
|
|
292
|
-
qgis_process run /path/to/my_model.model3 -- INPUT=data.shp OUTPUT=result.shp
|
|
293
|
-
```
|
|
294
|
-
|
|
295
|
-
### 7. 运行 Python 脚本
|
|
296
|
-
|
|
297
|
-
```bash
|
|
298
|
-
qgis_process run /path/to/my_script.py -- INPUT=data.shp OUTPUT=result.shp
|
|
299
|
-
```
|
|
300
|
-
|
|
301
|
-
---
|
|
302
|
-
|
|
303
|
-
> 常用内置算法速查、参数类型参考与典型工作流示例见 [reference/algorithm-cheatsheet.md](reference/algorithm-cheatsheet.md)
|
|
304
|
-
|
|
305
|
-
## AI 使用建议
|
|
306
|
-
|
|
307
|
-
### 推荐工作流
|
|
308
|
-
|
|
309
|
-
1. **发现算法**:`qgis_process list` → 获取所有可用算法 ID
|
|
310
|
-
2. **查看帮助**:`qgis_process help <algorithm_id> --json` → 获取参数定义的 JSON
|
|
311
|
-
3. **构造参数**:根据 JSON 帮助信息构造参数
|
|
312
|
-
4. **执行算法**:`qgis_process run <algorithm_id> --json -- PARAM=VALUE ...` 或通过 STDIN 传入 JSON
|
|
313
|
-
5. **解析结果**:解析 JSON 输出获取结果路径和日志信息
|
|
314
|
-
|
|
315
|
-
### 关键注意事项
|
|
316
|
-
|
|
317
|
-
1. **始终使用 `--json` 选项**:JSON 输出结构化、易解析,是 AI 最友好的交互方式。
|
|
318
|
-
2. **先查 help 再构造参数**:每个算法的参数名和类型不同,先用 `help --json` 确认参数定义。
|
|
319
|
-
3. **枚举类型传数字索引**:枚举参数用数字(如 `0`、`1`)而非文字。help 输出的 `available_options` 提供了索引到含义的映射。
|
|
320
|
-
4. **多值参数多次指定**:如 `LAYERS=a.shp LAYERS=b.shp`(在 `--` 之后,参数不带前导 `--`)。
|
|
321
|
-
5. **复杂参数用 STDIN JSON**:字典类型的参数值适合通过 STDIN JSON 方式传入。
|
|
322
|
-
6. **文件路径使用绝对路径**:避免工作目录不确定导致的文件找不到。
|
|
323
|
-
7. **Headless 环境设置 `QT_QPA_PLATFORM=offscreen`**:在无显示器的服务器上必须设置。
|
|
324
|
-
8. **需要项目文件的算法**:某些算法(如打印布局导出)需要通过 `--project_path` 指定项目文件。
|
|
325
|
-
9. **取消正在运行的算法**:使用 `CTRL+C` 可取消执行中的算法。
|
|
326
|
-
10. **`--no-python` 和 `--skip-loading-plugins` 可加速启动**:如果不需要第三方插件提供的算法,使用这两个选项可显著缩短启动时间。
|
|
327
|
-
|
|
328
|
-
### 错误处理
|
|
329
|
-
|
|
330
|
-
- 算法不存在:`Algorithm <id> not found!`
|
|
331
|
-
- 缺少必填参数:`The following mandatory parameters were not specified`
|
|
332
|
-
- 模型文件无效:`File <path> is not a valid Processing model!`
|
|
333
|
-
- Python 脚本无效:`File <path> is not a valid Processing script!`
|
|
334
|
-
- 算法不可在命令行使用:`The "<id>" algorithm is not available for use outside of the QGIS desktop application`
|
|
335
|
-
- 需要项目文件:`The "<id>" algorithm requires a QGIS project to execute`
|
|
336
|
-
|
|
337
|
-
---
|
|
338
|
-
|
|
339
|
-
## 算法 Provider 分类
|
|
340
|
-
|
|
341
|
-
| Provider ID | 说明 | 来源 |
|
|
342
|
-
|-------------|------|------|
|
|
343
|
-
| `native` | QGIS 原生 C++ 算法 | QGIS 内置 |
|
|
344
|
-
| `qgis` | QGIS Python 算法 | QGIS 内置 |
|
|
345
|
-
| `gdal` | GDAL/OGR 工具封装 | QGIS 内置 |
|
|
346
|
-
| `grass` | GRASS GIS 算法 | QGIS 内置(需 GRASS 安装) |
|
|
347
|
-
| `saga` | SAGA GIS 算法 | 插件提供 |
|
|
348
|
-
| `pdal` | 点云处理算法 | QGIS 内置(需 PDAL) |
|
|
349
|
-
| `3d` | 3D 分析算法 | QGIS 内置 |
|
|
350
|
-
| 其他 | 第三方插件 Provider | 各插件提供 |
|
|
351
|
-
|
|
352
|
-
---
|
|
353
|
-
|
|
354
|
-
## 常见问题
|
|
355
|
-
|
|
356
|
-
| 问题 | 解决方案 |
|
|
357
|
-
|------|---------|
|
|
358
|
-
| 提示 `command not found: qgis_process` | 将 QGIS 的 `bin` 目录加入 `PATH`;Windows 下改用 OSGeo4W Shell 运行 |
|
|
359
|
-
| 无显示器的服务器上崩溃或卡住 | 设置环境变量 `QT_QPA_PLATFORM=offscreen` |
|
|
360
|
-
| `Algorithm <id> not found!` | 用 `qgis_process list` 确认算法 ID 与 Provider 前缀(如 `native:`、`gdal:`) |
|
|
361
|
-
| 缺少必填参数 | 先用 `qgis_process help <id> --json` 查看参数名、类型与默认值 |
|
|
362
|
-
| 枚举参数报错 | 枚举值需传数字索引,`help --json` 中的 `available_options` 提供索引映射 |
|
|
363
|
-
| 多值参数只生效一项 | 在 `--` 之后多次指定同一参数(如 `LAYERS=a.shp LAYERS=b.shp`) |
|
|
364
|
-
| 路径含空格或中文时报错 | 使用绝对路径并对参数值加引号 |
|
|
365
|
-
| 启动速度慢 | 不需要 Python/插件时添加 `--no-python` 与 `--skip-loading-plugins` |
|
|
366
|
-
|
|
367
|
-
---
|
|
368
|
-
|
|
369
|
-
## 相关技能
|
|
370
|
-
|
|
371
|
-
- **pyqgis** — QGIS Python 绑定:[../pyqgis/SKILL.md](../pyqgis/SKILL.md)
|
|
372
|
-
- **gdal** — 命令行数据处理:[../gdal/SKILL.md](../gdal/SKILL.md)
|
|
373
|
-
- **geopipe-agent** — AI 原生分析流水线:[../geopipe-agent/SKILL.md](../geopipe-agent/SKILL.md)
|
|
374
|
-
- **geoserver-rest-api** — REST API 自动化:[../geoserver-rest-api/SKILL.md](../geoserver-rest-api/SKILL.md)
|
|
375
|
-
|
|
376
|
-
## 源码结构参考
|
|
377
|
-
|
|
378
|
-
源码位于 QGIS 仓库 `src/process/` 目录:
|
|
379
|
-
|
|
380
|
-
| 文件 | 说明 |
|
|
381
|
-
|------|------|
|
|
382
|
-
| `main.cpp` | 程序入口 |
|
|
383
|
-
| `qgsprocess.h` | `QgsProcessingExec` 类定义,包含命令分发、插件加载、算法执行等 |
|
|
384
|
-
| `qgsprocess.cpp` | 核心实现:`showUsage()`(帮助)、`listAlgorithms()`(列表)、`showAlgorithmHelp()`(算法帮助)、`execute()`(执行算法) |
|
|
385
|
-
| `CMakeLists.txt` | 构建配置 |
|
|
386
|
-
|
|
387
|
-
### 核心类
|
|
388
|
-
|
|
389
|
-
- **`QgsProcessingExec`**:命令行执行器,负责解析命令和参数、加载插件、执行算法
|
|
390
|
-
- **`ConsoleFeedback`**:继承自 `QgsProcessingFeedback`,处理控制台输出和进度显示,支持文本和 JSON 两种输出模式
|
|
391
|
-
- **`QgsProcessingExec::Flags`**:执行标志(`UseJson`、`SkipPython`、`SkipLoadingPlugins`)
|
|
392
|
-
|
|
393
|
-
### 关键方法
|
|
394
|
-
|
|
395
|
-
| 方法 | 说明 |
|
|
396
|
-
|------|------|
|
|
397
|
-
| `run(args, logLevel, flags)` | 主入口,解析命令行参数并分发到对应子命令 |
|
|
398
|
-
| `showUsage(appName)` | 输出使用帮助 |
|
|
399
|
-
| `showVersionInformation()` | 输出版本信息 |
|
|
400
|
-
| `listAlgorithms()` | 列出所有 Provider 和算法 |
|
|
401
|
-
| `listPlugins(useJson, showLoaded)` | 列出插件信息 |
|
|
402
|
-
| `enablePlugin(name, enabled)` | 启用/禁用插件 |
|
|
403
|
-
| `showAlgorithmHelp(id)` | 显示算法帮助(支持文本和 JSON 输出) |
|
|
404
|
-
| `execute(algId, parameters, ...)` | 执行算法核心逻辑 |
|
|
405
|
-
| `loadPlugins()` | 加载 Python 插件 |
|
|
406
|
-
|
|
407
|
-
## 参考资源
|
|
408
|
-
|
|
409
|
-
- **QGIS 源码:** <https://github.com/qgis/QGIS>
|
|
410
|
-
- **qgis_process 用户手册:** <https://docs.qgis.org/4.2/en/docs/user_manual/processing/standalone.html>
|
|
411
|
-
- **Processing 算法参考:** <https://docs.qgis.org/4.2/en/docs/user_manual/processing_algs/>
|
|
412
|
-
- **QGIS 下载(LTR/稳定版):** <https://qgis.org/download/>
|
|
413
|
-
- **QGIS 文档仓库:** <https://github.com/qgis/QGIS-Documentation>
|
|
414
|
-
- **中文教程(znlgis):** <https://znlgis.github.io/gis/tutorial/qgis/>
|
|
1
|
+
---
|
|
2
|
+
name: qgis-process
|
|
3
|
+
description: "Use when running QGIS geoprocessing tools headless from command line or CI/CD — buffer, clip, reproject, raster analysis without GUI. QGIS Processing: batch spatial analysis via qgis_process CLI."
|
|
4
|
+
tags:
|
|
5
|
+
- cli
|
|
6
|
+
- qgis
|
|
7
|
+
- processing
|
|
8
|
+
- raster
|
|
9
|
+
- automation
|
|
10
|
+
- batch
|
|
11
|
+
- ci-cd
|
|
12
|
+
- json
|
|
13
|
+
- workflow
|
|
14
|
+
- shell
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
> **项目地址:** <https://github.com/qgis/QGIS>
|
|
18
|
+
>
|
|
19
|
+
> **文档地址:** <https://github.com/qgis/QGIS-Documentation>
|
|
20
|
+
>
|
|
21
|
+
> **在线文档:** <https://docs.qgis.org/4.2/en/docs/user_manual/processing/standalone.html>
|
|
22
|
+
>
|
|
23
|
+
> **最新版本:** QGIS 4.2.3;3.44 LTR 最新 3.44.15(截至2026-10,GitHub Releases;`qgis_process` 自 QGIS 3.16 起可用)
|
|
24
|
+
>
|
|
25
|
+
> **许可证:** GPL-2.0+
|
|
26
|
+
|
|
27
|
+
## 概述
|
|
28
|
+
|
|
29
|
+
`qgis_process` 是 QGIS 自带的命令行工具(QGIS Processing Executor),允许在**不启动 QGIS 桌面应用**的情况下,直接从命令行运行 Processing 算法和模型(内置算法或由插件提供)。它适用于服务器端批量处理、CI/CD 自动化流水线、脚本化 GIS 工作流等场景。
|
|
30
|
+
|
|
31
|
+
源码位置:`src/process/` 目录下的 `main.cpp`、`qgsprocess.cpp`、`qgsprocess.h`。
|
|
32
|
+
|
|
33
|
+
---
|
|
34
|
+
|
|
35
|
+
## 环境准备
|
|
36
|
+
|
|
37
|
+
### 前置条件
|
|
38
|
+
|
|
39
|
+
- 安装 QGIS 3.16+(`qgis_process` 从 QGIS 3.16 开始可用)
|
|
40
|
+
- 确保 `qgis_process` 可执行文件在 `PATH` 中
|
|
41
|
+
|
|
42
|
+
### 安装方式
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
# Ubuntu/Debian
|
|
46
|
+
sudo apt install qgis
|
|
47
|
+
|
|
48
|
+
# Conda(跨平台)
|
|
49
|
+
conda install -c conda-forge qgis
|
|
50
|
+
|
|
51
|
+
# Docker(官方镜像,含 qgis_process;stable=4.2、ltr=3.44)
|
|
52
|
+
docker run --rm -v "$PWD:/data" qgis/qgis:ltr qgis_process --version
|
|
53
|
+
|
|
54
|
+
# Windows:通过 OSGeo4W 安装器安装 QGIS,随后在 "OSGeo4W Shell" 中运行 qgis_process
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
> **提示:** Windows 下手动运行的场景,将 QGIS 安装目录的 `bin`(如 `C:\Program Files\QGIS 3.44\bin` 或 `C:\OSGeo4W\bin`)加入 `PATH`。
|
|
58
|
+
|
|
59
|
+
### 无窗口系统(Headless 服务器)
|
|
60
|
+
|
|
61
|
+
在没有窗口管理器的系统上运行前,需设置环境变量:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
export QT_QPA_PLATFORM=offscreen
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### 验证安装
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
qgis_process --version
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
---
|
|
74
|
+
|
|
75
|
+
## 命令行语法
|
|
76
|
+
|
|
77
|
+
```text
|
|
78
|
+
qgis_process [--help] [--version] [--json] [--verbose] [--no-python] [--skip-loading-plugins] [command] [algorithm id | model path | script path] [parameters]
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### 全局选项
|
|
82
|
+
|
|
83
|
+
| 选项 | 说明 |
|
|
84
|
+
|------|------|
|
|
85
|
+
| `--help` 或 `-h` | 输出帮助信息 |
|
|
86
|
+
| `--version` 或 `-v` | 输出 QGIS Process 相关的所有版本信息 |
|
|
87
|
+
| `--json` | 以 JSON 格式输出结果(AI/脚本友好) |
|
|
88
|
+
| `--verbose` | 输出详细日志 |
|
|
89
|
+
| `--no-python` | 禁用 Python 支持(启动更快) |
|
|
90
|
+
| `--skip-loading-plugins` | 跳过加载已启用的插件(启动更快) |
|
|
91
|
+
|
|
92
|
+
### 可用命令
|
|
93
|
+
|
|
94
|
+
| 命令 | 说明 |
|
|
95
|
+
|------|------|
|
|
96
|
+
| `plugins` | 列出可用和已激活的插件 |
|
|
97
|
+
| `plugins enable <name>` | 启用已安装的插件 |
|
|
98
|
+
| `plugins disable <name>` | 禁用已安装的插件 |
|
|
99
|
+
| `list` | 列出所有可用的 Processing 算法 |
|
|
100
|
+
| `help <algorithm_id>` | 显示指定算法的帮助信息 |
|
|
101
|
+
| `run <algorithm_id> [-- PARAM=VALUE ...]` | 运行指定算法 |
|
|
102
|
+
|
|
103
|
+
> **注意:** 只有在 `metadata.txt` 中声明了 `hasProcessingProvider=yes` 的已安装插件才能被 `qgis_process` 识别和加载。
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
## 核心用法
|
|
108
|
+
|
|
109
|
+
### 1. 列出所有算法
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
qgis_process list
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
输出所有已注册 Provider 及其提供的算法 ID。
|
|
116
|
+
|
|
117
|
+
### 2. 查看算法帮助
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
qgis_process help qgis:regularpoints
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
输出算法的描述、参数列表(名称、类型、默认值、是否可选)和输出定义。
|
|
124
|
+
|
|
125
|
+
#### JSON 格式帮助(推荐 AI 使用)
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
qgis_process help native:buffer --json
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
JSON 输出结构:
|
|
132
|
+
|
|
133
|
+
```json
|
|
134
|
+
{
|
|
135
|
+
"qgis_version": "...",
|
|
136
|
+
"algorithm_details": {
|
|
137
|
+
"id": "native:buffer",
|
|
138
|
+
"name": "Buffer",
|
|
139
|
+
"tags": ["..."]
|
|
140
|
+
},
|
|
141
|
+
"provider_details": {
|
|
142
|
+
"id": "native",
|
|
143
|
+
"name": "QGIS (native c++)"
|
|
144
|
+
},
|
|
145
|
+
"parameters": {
|
|
146
|
+
"INPUT": {
|
|
147
|
+
"name": "INPUT",
|
|
148
|
+
"description": "Input layer",
|
|
149
|
+
"type": {
|
|
150
|
+
"id": "source",
|
|
151
|
+
"name": "Vector Features",
|
|
152
|
+
"acceptable_values": ["Path to a vector layer"]
|
|
153
|
+
},
|
|
154
|
+
"optional": false,
|
|
155
|
+
"default_value": null
|
|
156
|
+
},
|
|
157
|
+
"DISTANCE": {
|
|
158
|
+
"name": "DISTANCE",
|
|
159
|
+
"description": "Distance",
|
|
160
|
+
"type": {
|
|
161
|
+
"id": "distance",
|
|
162
|
+
"name": "Distance"
|
|
163
|
+
},
|
|
164
|
+
"optional": false,
|
|
165
|
+
"default_value": 10
|
|
166
|
+
},
|
|
167
|
+
"OUTPUT": {
|
|
168
|
+
"name": "OUTPUT",
|
|
169
|
+
"description": "Buffered",
|
|
170
|
+
"type": {
|
|
171
|
+
"id": "sink",
|
|
172
|
+
"name": "Vector Layer Destination"
|
|
173
|
+
},
|
|
174
|
+
"is_destination": true,
|
|
175
|
+
"optional": false
|
|
176
|
+
}
|
|
177
|
+
},
|
|
178
|
+
"outputs": {
|
|
179
|
+
"OUTPUT": {
|
|
180
|
+
"description": "Buffered",
|
|
181
|
+
"type": "outputVector"
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
### 3. 运行算法
|
|
188
|
+
|
|
189
|
+
#### 基本语法
|
|
190
|
+
|
|
191
|
+
```bash
|
|
192
|
+
qgis_process run <algorithm_id> -- PARAM1=VALUE1 PARAM2=VALUE2 ...
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
#### 示例:缓冲区分析
|
|
196
|
+
|
|
197
|
+
```bash
|
|
198
|
+
qgis_process run native:buffer -- INPUT=source.shp DISTANCE=2 OUTPUT=buffered.shp
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
#### 示例:合并图层(多值参数)
|
|
202
|
+
|
|
203
|
+
同一参数多次指定即可传入列表值:
|
|
204
|
+
|
|
205
|
+
```bash
|
|
206
|
+
qgis_process run native:mergevectorlayers -- LAYERS=input1.shp LAYERS=input2.shp OUTPUT=merged.shp
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
#### `run` 命令附加选项
|
|
210
|
+
|
|
211
|
+
| 选项 | 说明 |
|
|
212
|
+
|------|------|
|
|
213
|
+
| `--json` | 以 JSON 格式输出执行结果 |
|
|
214
|
+
| `--ellipsoid=<name>` | 指定椭球体,用于距离和面积计算 |
|
|
215
|
+
| `--distance_units=<unit>` | 指定距离单位 |
|
|
216
|
+
| `--area_units=<unit>` | 指定面积单位 |
|
|
217
|
+
| `--project_path=<path>` | 加载已有 QGIS 项目文件供算法执行时使用 |
|
|
218
|
+
|
|
219
|
+
#### JSON 格式运行结果
|
|
220
|
+
|
|
221
|
+
```bash
|
|
222
|
+
qgis_process run native:buffer --json -- INPUT=source.shp DISTANCE=2 OUTPUT=buffered.shp
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
JSON 输出结构:
|
|
226
|
+
|
|
227
|
+
```json
|
|
228
|
+
{
|
|
229
|
+
"qgis_version": "...",
|
|
230
|
+
"algorithm_details": { "id": "native:buffer" },
|
|
231
|
+
"inputs": {
|
|
232
|
+
"INPUT": "source.shp",
|
|
233
|
+
"DISTANCE": "2",
|
|
234
|
+
"OUTPUT": "buffered.shp"
|
|
235
|
+
},
|
|
236
|
+
"results": {
|
|
237
|
+
"OUTPUT": "/full/path/to/buffered.shp"
|
|
238
|
+
},
|
|
239
|
+
"log": ["..."]
|
|
240
|
+
}
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
### 4. 通过 STDIN 传入 JSON 参数(复杂参数)
|
|
244
|
+
|
|
245
|
+
当参数本身是复杂对象(如字典类型)时,可通过 STDIN 传入 JSON:
|
|
246
|
+
|
|
247
|
+
```bash
|
|
248
|
+
qgis_process run <algorithm_id> -
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
末尾的 `-` 表示从 STDIN 读取参数。JSON 必须包含 `"inputs"` 键:
|
|
252
|
+
|
|
253
|
+
```bash
|
|
254
|
+
echo '{"inputs": {"INPUT": "my_shape.shp", "DISTANCE": 5}}' | qgis_process run native:buffer -
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
完整 JSON 结构(含可选配置):
|
|
258
|
+
|
|
259
|
+
```json
|
|
260
|
+
{
|
|
261
|
+
"ellipsoid": "EPSG:7019",
|
|
262
|
+
"distance_units": "feet",
|
|
263
|
+
"area_units": "ha",
|
|
264
|
+
"project_path": "/path/to/project.qgs",
|
|
265
|
+
"inputs": {
|
|
266
|
+
"INPUT": "my_shape.shp",
|
|
267
|
+
"DISTANCE": 5,
|
|
268
|
+
"SEGMENTS": 8,
|
|
269
|
+
"OUTPUT": "output.shp"
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
> **注意:** 通过 STDIN 传入 JSON 时,输出自动使用 JSON 格式。
|
|
275
|
+
|
|
276
|
+
### 5. 插件管理
|
|
277
|
+
|
|
278
|
+
```bash
|
|
279
|
+
# 列出插件
|
|
280
|
+
qgis_process plugins
|
|
281
|
+
|
|
282
|
+
# 启用插件
|
|
283
|
+
qgis_process plugins enable cartography_tools
|
|
284
|
+
|
|
285
|
+
# 禁用插件
|
|
286
|
+
qgis_process plugins disable cartography_tools
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
### 6. 运行模型文件
|
|
290
|
+
|
|
291
|
+
```bash
|
|
292
|
+
qgis_process run /path/to/my_model.model3 -- INPUT=data.shp OUTPUT=result.shp
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
### 7. 运行 Python 脚本
|
|
296
|
+
|
|
297
|
+
```bash
|
|
298
|
+
qgis_process run /path/to/my_script.py -- INPUT=data.shp OUTPUT=result.shp
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
---
|
|
302
|
+
|
|
303
|
+
> 常用内置算法速查、参数类型参考与典型工作流示例见 [reference/algorithm-cheatsheet.md](reference/algorithm-cheatsheet.md)
|
|
304
|
+
|
|
305
|
+
## AI 使用建议
|
|
306
|
+
|
|
307
|
+
### 推荐工作流
|
|
308
|
+
|
|
309
|
+
1. **发现算法**:`qgis_process list` → 获取所有可用算法 ID
|
|
310
|
+
2. **查看帮助**:`qgis_process help <algorithm_id> --json` → 获取参数定义的 JSON
|
|
311
|
+
3. **构造参数**:根据 JSON 帮助信息构造参数
|
|
312
|
+
4. **执行算法**:`qgis_process run <algorithm_id> --json -- PARAM=VALUE ...` 或通过 STDIN 传入 JSON
|
|
313
|
+
5. **解析结果**:解析 JSON 输出获取结果路径和日志信息
|
|
314
|
+
|
|
315
|
+
### 关键注意事项
|
|
316
|
+
|
|
317
|
+
1. **始终使用 `--json` 选项**:JSON 输出结构化、易解析,是 AI 最友好的交互方式。
|
|
318
|
+
2. **先查 help 再构造参数**:每个算法的参数名和类型不同,先用 `help --json` 确认参数定义。
|
|
319
|
+
3. **枚举类型传数字索引**:枚举参数用数字(如 `0`、`1`)而非文字。help 输出的 `available_options` 提供了索引到含义的映射。
|
|
320
|
+
4. **多值参数多次指定**:如 `LAYERS=a.shp LAYERS=b.shp`(在 `--` 之后,参数不带前导 `--`)。
|
|
321
|
+
5. **复杂参数用 STDIN JSON**:字典类型的参数值适合通过 STDIN JSON 方式传入。
|
|
322
|
+
6. **文件路径使用绝对路径**:避免工作目录不确定导致的文件找不到。
|
|
323
|
+
7. **Headless 环境设置 `QT_QPA_PLATFORM=offscreen`**:在无显示器的服务器上必须设置。
|
|
324
|
+
8. **需要项目文件的算法**:某些算法(如打印布局导出)需要通过 `--project_path` 指定项目文件。
|
|
325
|
+
9. **取消正在运行的算法**:使用 `CTRL+C` 可取消执行中的算法。
|
|
326
|
+
10. **`--no-python` 和 `--skip-loading-plugins` 可加速启动**:如果不需要第三方插件提供的算法,使用这两个选项可显著缩短启动时间。
|
|
327
|
+
|
|
328
|
+
### 错误处理
|
|
329
|
+
|
|
330
|
+
- 算法不存在:`Algorithm <id> not found!`
|
|
331
|
+
- 缺少必填参数:`The following mandatory parameters were not specified`
|
|
332
|
+
- 模型文件无效:`File <path> is not a valid Processing model!`
|
|
333
|
+
- Python 脚本无效:`File <path> is not a valid Processing script!`
|
|
334
|
+
- 算法不可在命令行使用:`The "<id>" algorithm is not available for use outside of the QGIS desktop application`
|
|
335
|
+
- 需要项目文件:`The "<id>" algorithm requires a QGIS project to execute`
|
|
336
|
+
|
|
337
|
+
---
|
|
338
|
+
|
|
339
|
+
## 算法 Provider 分类
|
|
340
|
+
|
|
341
|
+
| Provider ID | 说明 | 来源 |
|
|
342
|
+
|-------------|------|------|
|
|
343
|
+
| `native` | QGIS 原生 C++ 算法 | QGIS 内置 |
|
|
344
|
+
| `qgis` | QGIS Python 算法 | QGIS 内置 |
|
|
345
|
+
| `gdal` | GDAL/OGR 工具封装 | QGIS 内置 |
|
|
346
|
+
| `grass` | GRASS GIS 算法 | QGIS 内置(需 GRASS 安装) |
|
|
347
|
+
| `saga` | SAGA GIS 算法 | 插件提供 |
|
|
348
|
+
| `pdal` | 点云处理算法 | QGIS 内置(需 PDAL) |
|
|
349
|
+
| `3d` | 3D 分析算法 | QGIS 内置 |
|
|
350
|
+
| 其他 | 第三方插件 Provider | 各插件提供 |
|
|
351
|
+
|
|
352
|
+
---
|
|
353
|
+
|
|
354
|
+
## 常见问题
|
|
355
|
+
|
|
356
|
+
| 问题 | 解决方案 |
|
|
357
|
+
|------|---------|
|
|
358
|
+
| 提示 `command not found: qgis_process` | 将 QGIS 的 `bin` 目录加入 `PATH`;Windows 下改用 OSGeo4W Shell 运行 |
|
|
359
|
+
| 无显示器的服务器上崩溃或卡住 | 设置环境变量 `QT_QPA_PLATFORM=offscreen` |
|
|
360
|
+
| `Algorithm <id> not found!` | 用 `qgis_process list` 确认算法 ID 与 Provider 前缀(如 `native:`、`gdal:`) |
|
|
361
|
+
| 缺少必填参数 | 先用 `qgis_process help <id> --json` 查看参数名、类型与默认值 |
|
|
362
|
+
| 枚举参数报错 | 枚举值需传数字索引,`help --json` 中的 `available_options` 提供索引映射 |
|
|
363
|
+
| 多值参数只生效一项 | 在 `--` 之后多次指定同一参数(如 `LAYERS=a.shp LAYERS=b.shp`) |
|
|
364
|
+
| 路径含空格或中文时报错 | 使用绝对路径并对参数值加引号 |
|
|
365
|
+
| 启动速度慢 | 不需要 Python/插件时添加 `--no-python` 与 `--skip-loading-plugins` |
|
|
366
|
+
|
|
367
|
+
---
|
|
368
|
+
|
|
369
|
+
## 相关技能
|
|
370
|
+
|
|
371
|
+
- **pyqgis** — QGIS Python 绑定:[../pyqgis/SKILL.md](../pyqgis/SKILL.md)
|
|
372
|
+
- **gdal** — 命令行数据处理:[../gdal/SKILL.md](../gdal/SKILL.md)
|
|
373
|
+
- **geopipe-agent** — AI 原生分析流水线:[../geopipe-agent/SKILL.md](../geopipe-agent/SKILL.md)
|
|
374
|
+
- **geoserver-rest-api** — REST API 自动化:[../geoserver-rest-api/SKILL.md](../geoserver-rest-api/SKILL.md)
|
|
375
|
+
|
|
376
|
+
## 源码结构参考
|
|
377
|
+
|
|
378
|
+
源码位于 QGIS 仓库 `src/process/` 目录:
|
|
379
|
+
|
|
380
|
+
| 文件 | 说明 |
|
|
381
|
+
|------|------|
|
|
382
|
+
| `main.cpp` | 程序入口 |
|
|
383
|
+
| `qgsprocess.h` | `QgsProcessingExec` 类定义,包含命令分发、插件加载、算法执行等 |
|
|
384
|
+
| `qgsprocess.cpp` | 核心实现:`showUsage()`(帮助)、`listAlgorithms()`(列表)、`showAlgorithmHelp()`(算法帮助)、`execute()`(执行算法) |
|
|
385
|
+
| `CMakeLists.txt` | 构建配置 |
|
|
386
|
+
|
|
387
|
+
### 核心类
|
|
388
|
+
|
|
389
|
+
- **`QgsProcessingExec`**:命令行执行器,负责解析命令和参数、加载插件、执行算法
|
|
390
|
+
- **`ConsoleFeedback`**:继承自 `QgsProcessingFeedback`,处理控制台输出和进度显示,支持文本和 JSON 两种输出模式
|
|
391
|
+
- **`QgsProcessingExec::Flags`**:执行标志(`UseJson`、`SkipPython`、`SkipLoadingPlugins`)
|
|
392
|
+
|
|
393
|
+
### 关键方法
|
|
394
|
+
|
|
395
|
+
| 方法 | 说明 |
|
|
396
|
+
|------|------|
|
|
397
|
+
| `run(args, logLevel, flags)` | 主入口,解析命令行参数并分发到对应子命令 |
|
|
398
|
+
| `showUsage(appName)` | 输出使用帮助 |
|
|
399
|
+
| `showVersionInformation()` | 输出版本信息 |
|
|
400
|
+
| `listAlgorithms()` | 列出所有 Provider 和算法 |
|
|
401
|
+
| `listPlugins(useJson, showLoaded)` | 列出插件信息 |
|
|
402
|
+
| `enablePlugin(name, enabled)` | 启用/禁用插件 |
|
|
403
|
+
| `showAlgorithmHelp(id)` | 显示算法帮助(支持文本和 JSON 输出) |
|
|
404
|
+
| `execute(algId, parameters, ...)` | 执行算法核心逻辑 |
|
|
405
|
+
| `loadPlugins()` | 加载 Python 插件 |
|
|
406
|
+
|
|
407
|
+
## 参考资源
|
|
408
|
+
|
|
409
|
+
- **QGIS 源码:** <https://github.com/qgis/QGIS>
|
|
410
|
+
- **qgis_process 用户手册:** <https://docs.qgis.org/4.2/en/docs/user_manual/processing/standalone.html>
|
|
411
|
+
- **Processing 算法参考:** <https://docs.qgis.org/4.2/en/docs/user_manual/processing_algs/>
|
|
412
|
+
- **QGIS 下载(LTR/稳定版):** <https://qgis.org/download/>
|
|
413
|
+
- **QGIS 文档仓库:** <https://github.com/qgis/QGIS-Documentation>
|
|
414
|
+
- **中文教程(znlgis):** <https://znlgis.github.io/gis/tutorial/qgis/>
|