cli-anything-qgis
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesecli-anything-qgis
cli-anything-qgis
Use this skill when you need to inspect or modify QGIS projects from the terminal through the real QGIS runtime.
当你需要通过真实QGIS运行时从终端检查或修改QGIS项目时,可以使用此工具。
Requirements
要求
- QGIS installed with on
qgis_processPATH - PyQGIS importable from the Python environment running the CLI
- Python 3.10+
- 已安装QGIS且在
qgis_process环境变量中PATH - 运行CLI的Python环境可导入PyQGIS
- Python 3.10+
Agent guidance
工具使用指引
- Prefer for all machine-driven use.
--json - For one-shot commands, pass when operating on an existing project.
--project <path> - Running with no subcommand starts a stateful REPL.
cli-anything-qgis - Layout export is backed by real QGIS processing algorithms:
native:printlayouttopdfnative:printlayouttoimage
- 所有机器驱动的使用场景优先使用参数。
--json - 对于一次性命令,操作现有项目时需传入参数。
--project <路径> - 不带任何子命令运行会启动有状态的REPL交互环境。
cli-anything-qgis - 布局导出基于真实的QGIS处理算法:
native:printlayouttopdfnative:printlayouttoimage
What this CLI covers
该CLI支持的功能
- create, open, save, and inspect /
.qgsprojects.qgz - create writable GeoPackage-backed vector layers
- add features via WKT geometry and typed attributes
key=value - create print layouts and add map/label items
- export layouts to PDF or image
- inspect and run generic algorithms
qgis_process - inspect session status and history
- 创建、打开、保存和检查/
.qgs格式的项目.qgz - 创建基于GeoPackage的可编辑矢量图层
- 通过WKT几何格式和带类型的属性添加要素
key=value - 创建打印布局并添加地图/标签项
- 将布局导出为PDF或图片格式
- 检查并运行通用算法
qgis_process - 检查会话状态和历史记录
Command groups
命令组
project
projectproject
projectnew -o/--output [--title] [--crs]open PATHsave [PATH]infoset-crs CRS
new -o/--output [--title] [--crs]open PATHsave [PATH]infoset-crs CRS
layer
layerlayer
layercreate-vector --name --geometry --crs [--field name:type ...]listinfo LAYERremove LAYER
create-vector --name --geometry --crs [--field name:type ...]listinfo LAYERremove LAYER
feature
featurefeature
featureadd --layer LAYER --wkt WKT [--attr key=value ...]list --layer LAYER [--limit N]
add --layer LAYER --wkt WKT [--attr key=value ...]list --layer LAYER [--limit N]
layout
layoutlayout
layoutcreate --name [--page-size] [--orientation]listinfo LAYOUTremove LAYOUTadd-map --layout LAYOUT --x --y --width --height [--extent xmin,ymin,xmax,ymax]add-label --layout LAYOUT --text TEXT --x --y --width --height [--font-size N]
create --name [--page-size] [--orientation]listinfo LAYOUTremove LAYOUTadd-map --layout LAYOUT --x --y --width --height [--extent xmin,ymin,xmax,ymax]add-label --layout LAYOUT --text TEXT --x --y --width --height [--font-size N]
export
exportexport
exportpresetspdf OUTPUT --layout LAYOUT [--dpi] [--force-vector] [--force-raster] [--georeference/--no-georeference] [--overwrite]image OUTPUT --layout LAYOUT [--dpi] [--overwrite]
presetspdf OUTPUT --layout LAYOUT [--dpi] [--force-vector] [--force-raster] [--georeference/--no-georeference] [--overwrite]image OUTPUT --layout LAYOUT [--dpi] [--overwrite]
process
processprocess
processlisthelp ALGORITHM_IDrun ALGORITHM_ID [--param KEY=VALUE ...]
listhelp ALGORITHM_IDrun ALGORITHM_ID [--param KEY=VALUE ...]
session
sessionsession
sessionstatushistory [--limit N]
statushistory [--limit N]
Examples
示例
Create a project and add a writable layer
创建项目并添加可编辑图层
bash
cli-anything-qgis --json project new -o demo.qgz --title "Demo" --crs EPSG:4326
cli-anything-qgis --json --project demo.qgz layer create-vector \
--name places \
--geometry point \
--field name:string \
--field score:intbash
cli-anything-qgis --json project new -o demo.qgz --title "Demo" --crs EPSG:4326
cli-anything-qgis --json --project demo.qgz layer create-vector \
--name places \
--geometry point \
--field name:string \
--field score:intAdd features and inspect them
添加要素并检查
bash
cli-anything-qgis --json --project demo.qgz feature add \
--layer places \
--wkt "POINT(1 2)" \
--attr name=HQ \
--attr score=5
cli-anything-qgis --json --project demo.qgz feature list --layer places --limit 10bash
cli-anything-qgis --json --project demo.qgz feature add \
--layer places \
--wkt "POINT(1 2)" \
--attr name=HQ \
--attr score=5
cli-anything-qgis --json --project demo.qgz feature list --layer places --limit 10Create and export a layout
创建并导出布局
bash
cli-anything-qgis --json --project demo.qgz layout create --name Main
cli-anything-qgis --json --project demo.qgz layout add-map --layout Main --x 10 --y 20 --width 180 --height 120
cli-anything-qgis --json --project demo.qgz layout add-label --layout Main --text "Demo map" --x 10 --y 8 --width 100 --height 10
cli-anything-qgis --json --project demo.qgz export pdf output.pdf --layout Main --overwritebash
cli-anything-qgis --json --project demo.qgz layout create --name Main
cli-anything-qgis --json --project demo.qgz layout add-map --layout Main --x 10 --y 20 --width 180 --height 120
cli-anything-qgis --json --project demo.qgz layout add-label --layout Main --text "Demo map" --x 10 --y 8 --width 100 --height 10
cli-anything-qgis --json --project demo.qgz export pdf output.pdf --layout Main --overwriteInspect or run processing algorithms
检查或运行处理算法
bash
cli-anything-qgis --json process help native:buffer
cli-anything-qgis --json --project demo.qgz process run native:buffer \
--param INPUT=/tmp/demo_data.gpkg|layername=places \
--param DISTANCE=1 \
--param SEGMENTS=8 \
--param END_CAP_STYLE=0 \
--param JOIN_STYLE=0 \
--param MITER_LIMIT=2 \
--param DISSOLVE=false \
--param OUTPUT=/tmp/buffer.geojsonbash
cli-anything-qgis --json process help native:buffer
cli-anything-qgis --json --project demo.qgz process run native:buffer \
--param INPUT=/tmp/demo_data.gpkg|layername=places \
--param DISTANCE=1 \
--param SEGMENTS=8 \
--param END_CAP_STYLE=0 \
--param JOIN_STYLE=0 \
--param MITER_LIMIT=2 \
--param DISSOLVE=false \
--param OUTPUT=/tmp/buffer.geojsonREPL
REPL交互环境
bash
cli-anything-qgisExample interactive flow:
text
project new -o demo.qgz --title "Demo"
layer create-vector --name places --geometry point --field name:string
feature add --layer places --wkt "POINT(1 2)" --attr name=HQ
layout create --name Main
session status
quitbash
cli-anything-qgis示例交互流程:
text
project new -o demo.qgz --title "Demo"
layer create-vector --name places --geometry point --field name:string
feature add --layer places --wkt "POINT(1 2)" --attr name=HQ
layout create --name Main
session status
quit