Cli Anything Qgis

作者 hkuds34f519533bc1无许可证51K 个星标收录于 2026年10月8日更新于 2026年10月8日仓库2周前更新

Stateful QGIS CLI for projects, writable layers, features, layouts, exports, and qgis_process operations using the real QGIS runtime.

仅含说明Data & Analytics
AI 生成的概览

通过有状态的命令行界面在终端中操作 QGIS,管理项目、图层、要素、布局与导出。

功能
该技能介绍了一个面向真实 QGIS 运行时的有状态命令行界面,涵盖 .qgs 与 .qgz 项目的创建、打开、保存和查看。它还涵盖基于 GeoPackage 的可写矢量图层、使用 WKT 几何和带类型属性添加要素、包含地图与标注项的打印布局,以及将布局导出为 PDF 或图像。此外还提供通用 qgis_process 算法的查看与运行,以及会话状态和历史记录。
适用场景
当你需要在终端而非 QGIS 桌面应用中查看或修改 QGIS 项目时使用。它适合脚本化或由智能体驱动的地理空间工作,例如创建项目、添加图层与要素、编排打印布局、导出地图或运行处理算法。
运行要求
需要安装 QGIS 并确保 qgis_process 位于 PATH 中,运行该 CLI 的 Python 环境可导入 PyQGIS,且 Python 版本为 3.10 或更高。该技能不附带脚本,仅为说明文档。

cli-anything-qgis

Use this skill when you need to inspect or modify QGIS projects from the terminal through the real QGIS runtime.

Requirements

  • QGIS installed with qgis_process on PATH
  • PyQGIS importable from the Python environment running the CLI
  • Python 3.10+

Agent guidance

  • Prefer --json for all machine-driven use.
  • For one-shot commands, pass --project <path> when operating on an existing project.
  • Running cli-anything-qgis with no subcommand starts a stateful REPL.
  • Layout export is backed by real QGIS processing algorithms:
    • native:printlayouttopdf
    • native:printlayouttoimage

What this CLI covers

  • create, open, save, and inspect .qgs / .qgz projects
  • create writable GeoPackage-backed vector layers
  • add features via WKT geometry and typed key=value attributes
  • create print layouts and add map/label items
  • export layouts to PDF or image
  • inspect and run generic qgis_process algorithms
  • inspect session status and history

Command groups

project

  • new -o/--output [--title] [--crs]
  • open PATH
  • save [PATH]
  • info
  • set-crs CRS

layer

  • create-vector --name --geometry --crs [--field name:type ...]
  • list
  • info LAYER
  • remove LAYER

feature

  • add --layer LAYER --wkt WKT [--attr key=value ...]
  • list --layer LAYER [--limit N]

layout

  • create --name [--page-size] [--orientation]
  • list
  • info LAYOUT
  • remove LAYOUT
  • add-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

  • presets
  • pdf OUTPUT --layout LAYOUT [--dpi] [--force-vector] [--force-raster] [--georeference/--no-georeference] [--overwrite]
  • image OUTPUT --layout LAYOUT [--dpi] [--overwrite]

process

  • list
  • help ALGORITHM_ID
  • run ALGORITHM_ID [--param KEY=VALUE ...]

session

  • status
  • history [--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:4326cli-anything-qgis --json --project demo.qgz layer create-vector \  --name places \  --geometry point \  --field name:string \  --field score:int

Add 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 10

Create and export a layout

bash
cli-anything-qgis --json --project demo.qgz layout create --name Maincli-anything-qgis --json --project demo.qgz layout add-map --layout Main --x 10 --y 20 --width 180 --height 120cli-anything-qgis --json --project demo.qgz layout add-label --layout Main --text "Demo map" --x 10 --y 8 --width 100 --height 10cli-anything-qgis --json --project demo.qgz export pdf output.pdf --layout Main --overwrite

Inspect or run processing algorithms

bash
cli-anything-qgis --json process help native:buffercli-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.geojson

REPL

bash
cli-anything-qgis

Example interactive flow:

text
project new -o demo.qgz --title "Demo"layer create-vector --name places --geometry point --field name:stringfeature add --layer places --wkt "POINT(1 2)" --attr name=HQlayout create --name Mainsession statusquit

来源与署名

来源:hkuds/cli-anything位于skills/cli-anything-qgis提交34f5195

许可证: 无许可证

内容归原作者所有。SourceWeft 从公开仓库中收录这些内容。

举报或申请下架