@dsh-gis/dsh-opengis-skill 0.1.3 → 0.3.0

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.
Files changed (117) hide show
  1. package/CHANGELOG.md +95 -0
  2. package/README.md +68 -28
  3. package/THIRD_PARTY_NOTICES.md +9 -0
  4. package/adaptations/brutile.md +8 -0
  5. package/adaptations/cesiumjs.md +8 -0
  6. package/adaptations/common.md +19 -0
  7. package/adaptations/deck-gl.md +8 -0
  8. package/adaptations/duckdb-spatial.md +8 -0
  9. package/adaptations/gdal-api.md +8 -0
  10. package/adaptations/gdal.md +8 -0
  11. package/adaptations/geolibre.md +8 -0
  12. package/adaptations/geometry-api-java.md +8 -0
  13. package/adaptations/geometry-api-net.md +8 -0
  14. package/adaptations/geonode.md +8 -0
  15. package/adaptations/geopandas.md +8 -0
  16. package/adaptations/geopipe-agent.md +8 -0
  17. package/adaptations/geoserver-cloud.md +8 -0
  18. package/adaptations/geoserver-rest-api.md +8 -0
  19. package/adaptations/geoserver.md +8 -0
  20. package/adaptations/geotools.md +8 -0
  21. package/adaptations/grass-gis.md +8 -0
  22. package/adaptations/jts.md +8 -0
  23. package/adaptations/kepler-gl.md +8 -0
  24. package/adaptations/leaflet.md +8 -0
  25. package/adaptations/mapbox-gl-js.md +8 -0
  26. package/adaptations/mapserver.md +8 -0
  27. package/adaptations/mapsui.md +8 -0
  28. package/adaptations/nettopologysuite.md +8 -0
  29. package/adaptations/opengis-all.md +9 -0
  30. package/adaptations/opengis-daf.md +9 -0
  31. package/adaptations/opengis-utils-for-java.md +8 -0
  32. package/adaptations/opengis-utils-for-net.md +8 -0
  33. package/adaptations/openlayers.md +8 -0
  34. package/adaptations/pdal.md +8 -0
  35. package/adaptations/postgis.md +8 -0
  36. package/adaptations/proj.md +8 -0
  37. package/adaptations/projnet4geoapi.md +8 -0
  38. package/adaptations/pyqgis.md +8 -0
  39. package/adaptations/qgis-process.md +8 -0
  40. package/adaptations/qgis-server.md +8 -0
  41. package/adaptations/shapely.md +8 -0
  42. package/adaptations/sharpmap.md +8 -0
  43. package/adaptations/spatialite.md +8 -0
  44. package/adaptations/whitebox-tools.md +8 -0
  45. package/assets/brutile/SKILL.md +283 -0
  46. package/assets/cesiumjs/SKILL.md +81 -35
  47. package/assets/deck-gl/SKILL.md +26 -34
  48. package/assets/duckdb-spatial/SKILL.md +363 -0
  49. package/assets/gdal/SKILL.md +55 -33
  50. package/assets/gdal/reference/raster-tools.md +14 -0
  51. package/assets/gdal/reference/vector-tools.md +5 -0
  52. package/assets/gdal-api/SKILL.md +12 -18
  53. package/assets/gdal-api/reference/raster-api.md +7 -0
  54. package/assets/gdal-api/reference/vector-api.md +9 -0
  55. package/assets/geolibre/SKILL.md +357 -0
  56. package/assets/geometry-api-java/SKILL.md +10 -16
  57. package/assets/geometry-api-net/SKILL.md +70 -32
  58. package/assets/geometry-api-net/reference/geometry-types.md +5 -0
  59. package/assets/geonode/SKILL.md +340 -0
  60. package/assets/geopandas/SKILL.md +21 -24
  61. package/assets/geopandas/reference/core-api.md +4 -0
  62. package/assets/geopipe-agent/SKILL.md +29 -31
  63. package/assets/geopipe-agent/reference/steps-reference.md +12 -0
  64. package/assets/geopipe-agent/reference/workflows.md +8 -0
  65. package/assets/geoserver/SKILL.md +10 -15
  66. package/assets/geoserver-cloud/SKILL.md +25 -33
  67. package/assets/geoserver-rest-api/SKILL.md +17 -19
  68. package/assets/geoserver-rest-api/reference/endpoints.md +16 -0
  69. package/assets/geotools/SKILL.md +12 -17
  70. package/assets/geotools/reference/raster-rendering.md +5 -0
  71. package/assets/geotools/reference/vector-io.md +7 -0
  72. package/assets/grass-gis/SKILL.md +26 -33
  73. package/assets/jts/SKILL.md +12 -16
  74. package/assets/jts/reference/geometry-operations.md +13 -0
  75. package/assets/kepler-gl/SKILL.md +306 -0
  76. package/assets/leaflet/SKILL.md +58 -40
  77. package/assets/mapbox-gl-js/SKILL.md +26 -33
  78. package/assets/mapserver/SKILL.md +21 -29
  79. package/assets/mapsui/SKILL.md +109 -63
  80. package/assets/nettopologysuite/SKILL.md +96 -31
  81. package/assets/opengis-all/SKILL.md +91 -289
  82. package/assets/opengis-all/reference/data-stages.md +269 -4
  83. package/assets/opengis-all/reference/workflow-cheatsheets.md +7 -0
  84. package/assets/opengis-daf/SKILL.md +10 -17
  85. package/assets/opengis-utils-for-java/SKILL.md +58 -49
  86. package/assets/opengis-utils-for-java/reference/common-tasks.md +16 -12
  87. package/assets/opengis-utils-for-net/SKILL.md +109 -48
  88. package/assets/opengis-utils-for-net/reference/code-patterns.md +15 -11
  89. package/assets/opengis-utils-for-net/reference/util-classes.md +35 -26
  90. package/assets/openlayers/SKILL.md +81 -28
  91. package/assets/pdal/SKILL.md +25 -27
  92. package/assets/postgis/SKILL.md +80 -35
  93. package/assets/proj/SKILL.md +32 -41
  94. package/assets/projnet4geoapi/SKILL.md +293 -0
  95. package/assets/pyqgis/SKILL.md +33 -30
  96. package/assets/pyqgis/reference/processing-rendering.md +6 -0
  97. package/assets/pyqgis/reference/vector-raster-layers.md +6 -0
  98. package/assets/qgis-process/SKILL.md +75 -33
  99. package/assets/qgis-process/reference/algorithm-cheatsheet.md +6 -0
  100. package/assets/qgis-server/SKILL.md +25 -31
  101. package/assets/shapely/SKILL.md +136 -84
  102. package/assets/shapely/reference/operations-reference.md +12 -0
  103. package/assets/sharpmap/SKILL.md +97 -60
  104. package/assets/spatialite/SKILL.md +358 -0
  105. package/assets/whitebox-tools/SKILL.md +262 -0
  106. package/lib/adaptations.d.ts +53 -0
  107. package/lib/adaptations.js +343 -0
  108. package/lib/catalog.d.ts +7 -1
  109. package/lib/catalog.js +9 -1
  110. package/lib/index.d.ts +10 -1
  111. package/lib/index.js +34 -3
  112. package/lib/skill-file.d.ts +12 -0
  113. package/lib/skill-file.js +133 -18
  114. package/locale/en.json +1 -1
  115. package/locale/zh.json +1 -1
  116. package/package.json +12 -2
  117. package/upstream.json +73 -57
@@ -0,0 +1,293 @@
1
+ ---
2
+ name: projnet4geoapi
3
+ description: "Use when transforming coordinates or reading CRS definitions in .NET with ProjNet 2.1.0 (NuGet ProjNet, repo ProjNet4GeoAPI) — CoordinateSystemFactory.CreateFromWkt, CoordinateTransformationFactory.CreateFromCoordinateSystems, MathTransform.Transform, CoordinateSystemServices SRID registration. Also for 'no suitable transformation' / null from GetCoordinateSystem, EPSG codes beyond 4326 and 3857 returning null, and SharpMap projects needing the legacy ProjNet4GeoAPI 1.4.1 GeoAPI build."
4
+ license: MIT
5
+ metadata:
6
+ category: gis
7
+ tags: "dotnet, csharp, coordinate-systems, projection, epsg, wkt, geospatial, netstandard, sharpmap"
8
+ ---
9
+
10
+ > **项目地址:** <https://github.com/NetTopologySuite/ProjNet4GeoAPI>
11
+ >
12
+ > **最新版本:** 2.1.0(截至 2026-11,[NuGet `ProjNet`](https://www.nuget.org/packages/ProjNet),netstandard2.0 / netstandard2.1)
13
+ >
14
+ > **NuGet(1.x,旧版):** `ProjNet4GeoAPI` 1.4.1(面向 GeoAPI 接口的项目,如 SharpMap 1.2)
15
+ >
16
+ > **官方文档:** <https://github.com/NetTopologySuite/ProjNet4GeoAPI/wiki>
17
+ >
18
+ > **许可证:** LGPL-2.1-or-later
19
+ >
20
+ > **维护状态:** 上游 README 明确说明维护资源不足,官方给出的替代方案是 SharpProj、DotSpatial.Projections、GDAL;新项目在需要完整 EPSG 支持时应优先考虑这些方案。
21
+
22
+ ## 概述
23
+
24
+ ProjNet 是 SharpMap 时代延续下来的 .NET 坐标参考系与投影引擎,按 OGC Simple Features 模型描述坐标系,负责「点对点」的坐标转换:源坐标系 → 目标坐标系,中间可能包含基准面转换(datum transformation)。它不提供地图渲染,也不自带 EPSG 数据库,坐标系定义要么用内置常量(WGS84、WebMercator),要么由调用方提供 WKT。
25
+
26
+ - **坐标系模型**:地理坐标系、地心坐标系、投影坐标系、垂直坐标系、复合坐标系
27
+ - **转换能力**:基准面转换、地理↔投影、投影↔投影,支持 Albers、Mercator、Transverse Mercator、Lambert Conformal Conic、Polar Stereographic、Krovak 等常用投影
28
+ - **定义读写**:WKT 与 XML 互转(`CreateFromWkt` / `CreateFromXml`)
29
+ - **服务容器**:`CoordinateSystemServices` 维护 SRID → 坐标系映射与转换工厂,默认只注册 EPSG:4326 与 EPSG:3857
30
+ - **两代包**:2.x 用自带类型体系(`ProjNet.CoordinateSystems`),1.x 实现 GeoAPI 接口供 SharpMap 等老库使用
31
+
32
+ ---
33
+
34
+ ## 环境准备
35
+
36
+ ### 安装(.NET 6+ / netstandard2.0 兼容项目)
37
+
38
+ ```bash
39
+ # 2.x 系列(推荐)
40
+ dotnet add package ProjNet --version 2.1.0
41
+
42
+ # 1.x 系列:只在必须实现 GeoAPI 接口的老项目里使用(如 SharpMap 1.2)
43
+ dotnet add package ProjNet4GeoAPI --version 1.4.1
44
+ ```
45
+
46
+ ```powershell
47
+ # Package Manager Console
48
+ Install-Package ProjNet -Version 2.1.0
49
+ ```
50
+
51
+ 两个包的程序集名都是 `ProjNET.dll`,**不能同时引用**;同时引用会出现类型冲突与「找到多个同名类型」的编译错误。
52
+
53
+ ### 验证
54
+
55
+ ```csharp
56
+ using ProjNet.CoordinateSystems;
57
+ using ProjNet.CoordinateSystems.Transformations;
58
+
59
+ var src = GeographicCoordinateSystem.WGS84;
60
+ var tgt = ProjectedCoordinateSystem.WebMercator;
61
+ var transform = new CoordinateTransformationFactory()
62
+ .CreateFromCoordinateSystems(src, tgt);
63
+
64
+ double[] xy = transform.MathTransform.Transform(new[] {116.397, 39.908});
65
+ Console.WriteLine($"{xy[0]:F2}, {xy[1]:F2}"); // 约 12957254.80, 4852582.10
66
+ ```
67
+
68
+ ```bash
69
+ dotnet run # 能打印出 Web Mercator 米制坐标即环境正常
70
+ ```
71
+
72
+ ### 目标框架
73
+
74
+ | 包 | 目标框架 | 说明 |
75
+ |----|----------|------|
76
+ | `ProjNet` 2.1.0 | netstandard2.0 / netstandard2.1 | .NET Framework 4.6.1+、.NET 6/8/9 均可引用;netstandard2.0 版本额外依赖 `System.Memory` 4.6.0 |
77
+ | `ProjNet4GeoAPI` 1.4.1 | net35-client / net40-client / net45 / netstandard2.0 | 2018 年发布,只为兼容 GeoAPI 生态 |
78
+
79
+ ---
80
+
81
+ ## 核心 API
82
+
83
+ ### 坐标系工厂
84
+
85
+ ```csharp
86
+ using ProjNet.CoordinateSystems;
87
+
88
+ var factory = new CoordinateSystemFactory();
89
+
90
+ // 从 WKT 解析(EPSG 官网、GDAL 的 projinfo、QGIS 都能导出 WKT)
91
+ CoordinateSystem wgs84Utm50 = factory.CreateFromWkt(wktText);
92
+
93
+ // 从 XML 解析
94
+ CoordinateSystem fromXml = factory.CreateFromXml(xmlText);
95
+
96
+ // 组合式构造:以已有地理坐标系 + 投影参数创建投影坐标系
97
+ var gcs = GeographicCoordinateSystem.WGS84;
98
+ ```
99
+
100
+ | 成员 | 说明 |
101
+ |------|------|
102
+ | `CreateFromWkt(string)` | 解析 WKT,返回 `CoordinateSystem`;失败时可能返回 `null` |
103
+ | `CreateFromXml(string)` | 解析 ProjNet 自身的 XML 表示 |
104
+ | `CreateProjectedCoordinateSystem(...)` | 手工组装投影坐标系(名称、地理坐标系、投影、线性单位、轴) |
105
+ | `CreateGeographicCoordinateSystem(...)` | 手工组装地理坐标系(角度单位、基准面、本初子午线、轴) |
106
+ | `CreateProjection(name, className, parameters)` | 按投影类名与参数创建投影 |
107
+
108
+ 内置常量只有少数几个:`GeographicCoordinateSystem.WGS84`、`ProjectedCoordinateSystem.WebMercator`。其余坐标系必须自带 WKT。
109
+
110
+ ### 坐标转换
111
+
112
+ ```csharp
113
+ using ProjNet.CoordinateSystems;
114
+ using ProjNet.CoordinateSystems.Transformations;
115
+
116
+ var ctFactory = new CoordinateTransformationFactory();
117
+ ICoordinateTransformation ct = ctFactory.CreateFromCoordinateSystems(
118
+ sourceCS: factory.CreateFromWkt(wgs84Wkt),
119
+ targetCS: factory.CreateFromWkt(cgcs2000GaussKrugerWkt));
120
+
121
+ MathTransform mt = ct.MathTransform;
122
+
123
+ // 单点
124
+ double[] projected = mt.Transform(new[] {116.397, 39.908});
125
+
126
+ // 单点(元组重载,免去数组分配)
127
+ var (x, y) = mt.Transform(116.397, 39.908);
128
+
129
+ // 多点:一次调用处理整批,比循环 new 数组快得多
130
+ double[][] points = {new[] {116.0, 39.0}, new[] {117.0, 40.0}};
131
+ IList<double[]> projectedPoints = mt.TransformList(points);
132
+ ```
133
+
134
+ | 类型 / 成员 | 说明 |
135
+ |-------------|------|
136
+ | `ICoordinateTransformation.SourceCS` / `TargetCS` | 源与目标坐标系 |
137
+ | `ICoordinateTransformation.MathTransform` | 实际执行数值转换的数学变换 |
138
+ | `MathTransform.Transform(double[])` | 单点转换,输入 `[x, y]` 或 `[x, y, z]`,维度由变换决定 |
139
+ | `MathTransform.Transform(double x, double y)` | 元组重载,返回 `(x, y)` |
140
+ | `MathTransform.TransformList(IList<double[]>)` | 批量转换,返回转换后的点数组列表 |
141
+ | `MathTransform.Transform(Span<double> xs, Span<double> ys)` | 分离数组的 SOA 批量转换,适合大数组 |
142
+ | `MathTransform.Inverse()` | 取逆变换,用于反向换算 |
143
+
144
+ 坐标按 `x, y` 顺序解释(经度/东坐标在前,纬度/北坐标在后),ProjNet **不做轴序交换**;若拿到的 WKT 声明了 `AXIS["Latitude", NORTH]` 之类的轴序,需要调用方自行判断是否交换。
145
+
146
+ ### CoordinateSystemServices:SRID 与转换缓存
147
+
148
+ ```csharp
149
+ using ProjNet.CoordinateSystems;
150
+ using ProjNet.CoordinateSystems.Transformations;
151
+
152
+ var services = new CoordinateSystemServices();
153
+
154
+ // 默认只有 4326 与 3857
155
+ var wgs84 = services.GetCoordinateSystem(4326);
156
+ var mercator = services.GetCoordinateSystem(3857);
157
+
158
+ // 注册任意 EPSG 编码(值为 WKT 字符串)
159
+ var defs = new[]
160
+ {
161
+ new KeyValuePair<int, string>(4490, cgcs2000Wkt),
162
+ new KeyValuePair<int, string>(4547, cgcs2000GkCmwWkt),
163
+ };
164
+ var withDefs = new CoordinateSystemServices(defs);
165
+
166
+ ICoordinateTransformation ct = withDefs.CreateTransformation(4490, 4547);
167
+ double[] xy = ct.MathTransform.Transform(new[] {116.397, 39.908});
168
+ ```
169
+
170
+ | 成员 | 说明 |
171
+ |------|------|
172
+ | `new CoordinateSystemServices()` | 默认注册 4326、3857 两个坐标系 |
173
+ | `new CoordinateSystemServices(IEnumerable<KeyValuePair<int,string>>)` | 用 SRID → WKT 批量注册 |
174
+ | `GetCoordinateSystem(int srid)` | 按 SRID 取坐标系;未注册返回 `null` |
175
+ | `GetCoordinateSystem(string authority, long code)` | 按授权名与编码取(内部仍走 SRID 映射) |
176
+ | `GetSRID(string authority, long code)` | 反查 SRID,未注册返回 `null` |
177
+ | `CreateTransformation(int sourceSrid, int targetSrid)` | 按 SRID 建转换,最常用 |
178
+ | `CreateTransformation(CoordinateSystem, CoordinateSystem)` | 按对象建转换 |
179
+
180
+ 失败的 WKT 会被静默跳过:`CreateCoordinateSystem` 内部捕获异常并返回 `null`,因此「注册了但查不到」优先怀疑 WKT 本身不被支持(例如带 `ELLIPSOID` 关键字或使用了未实现的投影)。
181
+
182
+ ---
183
+
184
+ ## 典型工作流
185
+
186
+ 把一批 WGS84 经纬度点位转换到 CGCS2000 3 度带高斯-克吕格投影(EPSG:4547),并写回 CSV:
187
+
188
+ **输入**:`points.csv`(`lon,lat`)
189
+ **输出**:`points_projected.csv`(`lon,lat,x,y`)
190
+
191
+ 1. 用 `projinfo`(PROJ 命令行)导出目标坐标系的 WKT,避免手写投影参数
192
+ 2. 在代码里用 `CoordinateSystemServices` 注册 4490 与 4547
193
+ 3. 批量读取点位,调用 `MathTransform.Transform` 逐点或打包转换
194
+ 4. 输出前校验坐标量级(高斯投影的东坐标通常在 6 位数字量级)
195
+
196
+ ```bash
197
+ # 导出 WKT(PROJ 9.x)
198
+ projinfo EPSG:4547 -o WKT2:2019
199
+ ```
200
+
201
+ ```csharp
202
+ using System.Globalization;
203
+ using ProjNet.CoordinateSystems;
204
+ using ProjNet.CoordinateSystems.Transformations;
205
+
206
+ var cgcs2000 = File.ReadAllText("wkt/epsg4490.wkt");
207
+ var gk3d = File.ReadAllText("wkt/epsg4547.wkt");
208
+
209
+ var services = new CoordinateSystemServices(new[]
210
+ {
211
+ new KeyValuePair<int, string>(4490, cgcs2000),
212
+ new KeyValuePair<int, string>(4547, gk3d),
213
+ });
214
+
215
+ var ct = services.CreateTransformation(4490, 4547);
216
+ var mt = ct.MathTransform;
217
+
218
+ using var reader = new StreamReader("points.csv");
219
+ using var writer = new StreamWriter("points_projected.csv");
220
+ writer.WriteLine("lon,lat,x,y");
221
+
222
+ reader.ReadLine(); // 跳过表头
223
+ string? line;
224
+ while ((line = reader.ReadLine()) is not null)
225
+ {
226
+ var parts = line.Split(',');
227
+ double lon = double.Parse(parts[0], CultureInfo.InvariantCulture);
228
+ double lat = double.Parse(parts[1], CultureInfo.InvariantCulture);
229
+
230
+ double[] xy = mt.Transform(new[] {lon, lat});
231
+ writer.WriteLine(string.Join(",",
232
+ lon.ToString(CultureInfo.InvariantCulture),
233
+ lat.ToString(CultureInfo.InvariantCulture),
234
+ xy[0].ToString("F3", CultureInfo.InvariantCulture),
235
+ xy[1].ToString("F3", CultureInfo.InvariantCulture)));
236
+ }
237
+ ```
238
+
239
+ **检查点**:转换后东坐标应是 6 位数(含带号则 8 位),北坐标在 0–5000000 量级;若数值仍是 116 / 39 这样的量级,说明取错了坐标系或 WKT 解析失败被静默跳过。
240
+
241
+ ---
242
+
243
+ ## 最佳实践
244
+
245
+ 1. **WKT 由专业工具生成**:用 `projinfo`、`gdalsrsinfo` 或 EPSG 官网导出,不要手写 `PROJCS` 字符串,参数顺序错一位结果就偏
246
+ 2. **一次构造、复用实例**:`CoordinateTransformationFactory`、`CoordinateSystemFactory` 与 `MathTransform` 都可复用,避免在循环里重复解析 WKT
247
+ 3. **批量用 `TransformList` 或 `Span` 重载**:`MathTransform.TransformList(IList<double[]>)` 一次处理整批点;SOA 结构的大数组用 `Transform(Span<double> xs, Span<double> ys)` 避免装箱
248
+ 4. **校验转换前后的量级与范围**:投影坐标是米,经纬度是度;写一条断言比肉眼检查可靠
249
+ 5. **明确轴序**:ProjNet 只做 `x, y` 算术,不理会 WKT 的 `AXIS` 声明,跨系统交换数据时显式约定顺序
250
+ 6. **坐标是数值不是几何**:ProjNet 只处理点数组,几何对象的转换要自己遍历坐标(或用 NTS 的坐标过滤器)
251
+ 7. **考虑替代方案**:需要完整 EPSG 库、网格文件(NTv2/GTX)或 3D 基准转换时,用 SharpProj 或 GDAL,不要指望 ProjNet 覆盖
252
+
253
+ ---
254
+
255
+ ## 常见问题
256
+
257
+ | 问题 | 原因与解决 |
258
+ |------|------------|
259
+ | `CreateFromCoordinateSystems` 返回 `null` 或抛异常 | 源/目标坐标系类型组合不受支持(如两个地理坐标系之间只差基准面而缺少转换参数):改用「地理 → 投影」或先转 WGS84 再转目标 |
260
+ | `GetCoordinateSystem(4490)` 返回 `null` | `CoordinateSystemServices` 默认只注册 4326 与 3857:用 SRID → WKT 的构造函数注册,或直接 `CreateFromWkt` |
261
+ | 转换结果与 QGIS/GDAL 差几十米 | ProjNet 没有网格文件与最新基准面参数,只做近似七参数/三参数转换:高精度场景改用 SharpProj 或 GDAL |
262
+ | 注册了 WKT 但查不到坐标系 | `CreateCoordinateSystem` 会吞掉解析异常:先用 `new CoordinateSystemFactory().CreateFromWkt(wkt)` 单独验证,确认返回非 `null` |
263
+ | 经纬度转换结果是反的 | 输入数组按 `[x, y]` 解释,即经度在前:把 `[lat, lon]` 改成 `[lon, lat]` |
264
+ | 同时引用两个包后大量类型冲突 | `ProjNet` 2.x 与 `ProjNet4GeoAPI` 1.x 程序集同名:只保留一个;SharpMap 1.2 项目必须用 1.4.1 |
265
+ | 老项目里 `CoordinateTransformation` 赋值编译失败 | SharpMap 1.2 期望 GeoAPI 的 `ICoordinateTransformation`,2.x 不再实现该接口:换成 `ProjNet4GeoAPI` 1.4.1 |
266
+ | 大文件转换极慢 | 在循环里反复解析 WKT 或逐点 new 转换对象:把工厂、坐标系、`MathTransform` 提到循环外,并用打包数组接口 |
267
+
268
+ ---
269
+
270
+ ## AI 使用建议
271
+
272
+ - **执行环境**:`dotnet add package`、`dotnet build`、`dotnet run` 在终端中执行;首次 restore 需要访问 NuGet,失败时先看是否离线。
273
+ - **先探测版本**:`dotnet list package` 确认是 `ProjNet 2.1.0` 还是 `ProjNet4GeoAPI 1.4.1`——两者的命名空间与接口完全不同,写代码前必须确认,不要凭 `using ProjNet.CoordinateSystems` 猜。
274
+ - **WKT 来源**:让用户提供或先跑 `projinfo EPSG:xxxx -o WKT2:2019` 生成,再写进示例;不要凭空编造 `PROJCS` 参数。
275
+ - **验证产物**:编译后运行最小断言(如 116.397, 39.908 → Web Mercator 约 (12957254.8, 4852582.1)),数值量级不对就说明坐标系或轴序取错。
276
+ - **失败信号**:`null` 返回值优先怀疑 WKT 解析;结果偏差固定为几十米量级,是缺少网格文件而非代码错误。
277
+ - **安全与权限**:新建工程、装包前征得用户同意;示例里的 WKT 文件路径用占位符,不要写入用户真实数据路径。
278
+
279
+ ## 相关技能
280
+
281
+ - **nettopologysuite** — .NET 几何运算,常与 ProjNet 搭配做「几何转换 + 空间分析」:[../nettopologysuite/SKILL.md](../nettopologysuite/SKILL.md)
282
+ - **sharpmap** — 旧版 .NET 地图渲染库,坐标变换依赖 ProjNet/ProjNet4GeoAPI:[../sharpmap/SKILL.md](../sharpmap/SKILL.md)
283
+ - **mapsui** — 现代跨平台 .NET 地图组件,新项目优先考虑:[../mapsui/SKILL.md](../mapsui/SKILL.md)
284
+ - **proj** — PROJ 命令行,用于导出 WKT 与核对转换结果:[../proj/SKILL.md](../proj/SKILL.md)
285
+ - **gdal** — GDAL/OGR 命令行,可做高精度重投影与批量转换:[../gdal/SKILL.md](../gdal/SKILL.md)
286
+
287
+ ## 参考资源
288
+
289
+ - Wiki(FAQ、常用 WKT):<https://github.com/NetTopologySuite/ProjNet4GeoAPI/wiki>
290
+ - 源码:<https://github.com/NetTopologySuite/ProjNet4GeoAPI>
291
+ - NuGet(2.x):<https://www.nuget.org/packages/ProjNet>
292
+ - NuGet(1.x):<https://www.nuget.org/packages/ProjNet4GeoAPI>
293
+ - EPSG 坐标系查询:<https://epsg.org/>(EPSG 官方注册库;<https://spatialreference.org/> 可查 OGC WKT)
@@ -1,15 +1,10 @@
1
1
  ---
2
2
  name: pyqgis
3
- description: "Use when scripting QGIS with Python — QgsApplication standalone init, QgsVectorLayer / QgsRasterLayer loading, processing.run after Processing.initialize(), QgsGeometry / QgsExpression, QgsMapSettings rendering and QgsLayoutExporter PDF/PNG export, qgis._3d, or debugging \"import qgis.core\" failures. PyQGIS for QGIS 4.2.3 and LTR 3.44.15, Python 3.12."
4
- tags:
5
- - python
6
- - qgis
7
- - gis
8
- - processing
9
- - vector
10
- - raster
11
- - rendering
12
- - plugin
3
+ description: "Use when scripting QGIS with Python — QgsApplication standalone init, QgsVectorLayer / QgsRasterLayer loading, processing.run after Processing.initialize(), QgsGeometry / QgsExpression, QgsMapSettings rendering and QgsLayoutExporter PDF/PNG export, qgis._3d, or debugging \"import qgis.core\" failures. PyQGIS for QGIS 4.2.3 and LTR 3.44.15 (use the interpreter bundled with QGIS, not system Python)."
4
+ license: MIT
5
+ metadata:
6
+ category: gis
7
+ tags: "python, qgis, gis, processing, vector, raster, rendering, plugin"
13
8
  ---
14
9
 
15
10
  > **项目地址:** <https://github.com/qgis/QGIS>
@@ -18,7 +13,7 @@ tags:
18
13
  >
19
14
  > **Python API 参考:** <https://qgis.org/pyqgis/4.2/>
20
15
  >
21
- > **最新版本:** QGIS 4.2.3(截至 2026-10,[下载页](https://qgis.org/download/));LTR 3.44.15
16
+ > **最新版本:** QGIS 4.2.3(截至 2026-11,[下载页](https://qgis.org/download/));LTR 3.44.15
22
17
  >
23
18
  > **许可证:** GPL-2.0+
24
19
 
@@ -39,7 +34,7 @@ PyQGIS 主要包含以下模块:
39
34
  | `qgis.core` | 核心类——图层、要素、几何、坐标系、项目、Processing 等 |
40
35
  | `qgis.gui` | GUI 组件——地图画布、地图工具、符号选择器等 |
41
36
  | `qgis.analysis` | 空间分析——插值、网络分析、栅格计算等 |
42
- | `qgis.processing` | Processing 算法调用入口(`processing.run()`) |
37
+ | `processing` | Processing 算法调用入口(独立 Python 模块,`processing.run()`;非 `qgis.processing`) |
43
38
  | `qgis.server` | QGIS Server Python 插件接口 |
44
39
  | `qgis._3d` | 3D 地图视图相关类 |
45
40
  | `qgis.PyQt` | PyQt5/PyQt6 兼容层 |
@@ -51,7 +46,13 @@ PyQGIS 主要包含以下模块:
51
46
  ### 前置条件
52
47
 
53
48
  - 安装 QGIS 4.2+(当前稳定版)或 3.44 LTR(长期支持版)([查看 QGIS LTR/最新版](https://qgis.org/download/))
54
- - Python 3.12+(QGIS 4.x 自带的 Python 环境)
49
+ - 使用 **QGIS 发行包自带的 Python 解释器**(4.2 的 Windows 安装目录为 `apps/Python312`),不要用系统 Python 直接 `pip install qgis`
50
+
51
+ 探测发行包实际使用的解释器版本(在任何 QGIS Python 环境里):
52
+
53
+ ```bash
54
+ python -c "import sys; print(sys.version)"
55
+ ```
55
56
 
56
57
  ### 在 QGIS Python 控制台中使用
57
58
 
@@ -176,7 +177,7 @@ python3 my_pyqgis_script.py
176
177
 
177
178
  | 类 | 模块 | 用途 |
178
179
  |---|---|---|
179
- | `processing.run()` | `qgis.processing` | **执行 Processing 算法的核心入口** |
180
+ | `processing.run()` | `processing`(QGIS 插件目录模块) | **执行 Processing 算法的核心入口** |
180
181
  | `QgsProcessingFeedback` | `qgis.core` | 算法执行反馈(进度、日志) |
181
182
  | `QgsProcessingContext` | `qgis.core` | 算法执行上下文 |
182
183
  | `QgsProcessingAlgorithm` | `qgis.core` | 自定义算法基类 |
@@ -380,18 +381,6 @@ qgs.exitQgis()
380
381
 
381
382
  更多工作流(批量缓冲融合、栅格裁剪、打印布局导出)见 [reference/processing-rendering.md](reference/processing-rendering.md)。
382
383
 
383
- ## DeepSeek Harness 使用建议
384
-
385
- - **加载与引用**:用 `skill("pyqgis")` 加载(用户也可输入 `/pyqgis`);`reference/vector-raster-layers.md`、`reference/processing-rendering.md` 按需 `read`,路径相对 Base directory;技能目录只读,脚本、导出图与中间数据写到会话工作区。
386
- - **执行环境**:必须用 QGIS 自带的解释器(Windows 在 `C:\Program Files\QGIS 4.2\apps\Python312\python.exe`,LTR 为 `QGIS 3.44`),不要用系统 Python;命令交给 dsh 的 shell 工具(Windows 用 `pwsh`;仅暴露 `run_code` 的会话在 `tools.pwsh` 中执行),`export QT_QPA_PLATFORM=offscreen` 改写为 `$env:QT_QPA_PLATFORM = "offscreen"`。
387
- - **先探测版本**:`python -c "from qgis.core import Qgis; print(Qgis.QGIS_VERSION)"`;本技能同时覆盖 4.2.3(最新)与 3.44.15(LTR),4.x 与 3.x 存在 API 差异,回答里要写明按哪个版本写、低版本哪些类/方法不可用。
388
- - **验证产物**:独立脚本按 `QgsApplication` → `initQgis()` → 处理 → `exitQgis()` 收尾;写出后重开图层核对 `isValid()`、`featureCount()`、`crs().authid()`,`processing.run()` 的返回值只给路径,结果要二次打开;渲染或布局导出的 PNG 可用 `read_image` 看是否空白。
389
- - **模块名易错**:3D 模块是 `qgis._3d`(下划线,不是 `qgis.3d`),例如 `from qgis._3d import Qgs3DMapSettings`;`processing.run()` 前必须先 `Processing.initialize()`,否则报算法不存在。
390
- - **进程与日志**:批量脚本不要跨任务复用同一个 `QgsProject.instance()`;长任务放后台作业,QGIS 日志(`QgsApplication.messageLog()`)与 stderr 重定向到文件后分段 `read`。
391
- - **安全与权限**:`startEditing()`/`commitChanges()` 直接改源数据(Shapefile、PostGIS),先备份或把中间结果写 `memory:`;覆盖已有输出文件、安装 QGIS、把数据写进系统目录前先征得用户同意。
392
-
393
- ---
394
-
395
384
  ## 常见问题
396
385
 
397
386
  | 问题 | 解决 |
@@ -407,6 +396,18 @@ qgs.exitQgis()
407
396
 
408
397
  ---
409
398
 
399
+ ## AI 使用建议
400
+
401
+ - **本技能的组织**:主文件给高频用法,完整参数表与高级示例在 `reference/processing-rendering.md`、`reference/vector-raster-layers.md`,需要时再展开;示例工程与生成的数据写到工作目录,不要改动技能目录本身。
402
+ - **执行环境**:必须用 QGIS 自带的解释器(Windows 在 `C:\Program Files\QGIS 4.2\apps\Python312\python.exe`,LTR 为 `QGIS 3.44`),不要用系统 Python;命令在终端 / shell 中执行(Windows 用 PowerShell),`export QT_QPA_PLATFORM=offscreen` 改写为 `$env:QT_QPA_PLATFORM = "offscreen"`。
403
+ - **先探测版本**:`python -c "from qgis.core import Qgis; print(Qgis.QGIS_VERSION)"`;本技能同时覆盖 4.2.3(最新)与 3.44.15(LTR),4.x 与 3.x 存在 API 差异,回答里要写明按哪个版本写、低版本哪些类/方法不可用。
404
+ - **验证产物**:独立脚本按 `QgsApplication` → `initQgis()` → 处理 → `exitQgis()` 收尾;写出后重开图层核对 `isValid()`、`featureCount()`、`crs().authid()`,`processing.run()` 的返回值只给路径,结果要二次打开;渲染或布局导出的 PNG 要实际打开看是否空白。
405
+ - **模块名易错**:3D 模块是 `qgis._3d`(下划线,不是 `qgis.3d`),例如 `from qgis._3d import Qgs3DMapSettings`;`processing.run()` 前必须先 `Processing.initialize()`,否则报算法不存在。
406
+ - **进程与日志**:批量脚本不要跨任务复用同一个 `QgsProject.instance()`;长任务放后台运行,QGIS 日志(`QgsApplication.messageLog()`)与 stderr 重定向到文件后分段查看。
407
+ - **安全与权限**:`startEditing()`/`commitChanges()` 直接改源数据(Shapefile、PostGIS),先备份或把中间结果写 `memory:`;覆盖已有输出文件、安装 QGIS、把数据写进系统目录前先征得用户同意。
408
+
409
+ ---
410
+
410
411
  ## 相关技能
411
412
 
412
413
  - **qgis-process** — QGIS 命令行处理工具:[../qgis-process/SKILL.md](../qgis-process/SKILL.md)
@@ -418,8 +419,10 @@ qgs.exitQgis()
418
419
  ## 参考资源
419
420
 
420
421
  - **QGIS 源码仓库:** <https://github.com/qgis/QGIS>
421
- - **PyQGIS 开发者手册(3.44):** <https://docs.qgis.org/3.44/en/docs/pyqgis_developer_cookbook/>
422
- - **PyQGIS API 参考(3.44):** <https://qgis.org/pyqgis/3.44/>
422
+ - **PyQGIS 开发者手册(3.44,4.2 章节尚未定稿):** <https://docs.qgis.org/3.44/en/docs/pyqgis_developer_cookbook/>
423
+ - **PyQGIS API 参考(4.2):** <https://qgis.org/pyqgis/4.2/>
423
424
  - **QGIS 文档仓库:** <https://github.com/qgis/QGIS-Documentation>
424
- - **QGIS 用户手册:** <https://docs.qgis.org/3.44/en/docs/user_manual/>
425
- - **PyQGIS 速查表:** <https://docs.qgis.org/3.44/en/docs/pyqgis_developer_cookbook/cheat_sheet.html>
425
+ - **QGIS 用户手册(3.44):** <https://docs.qgis.org/3.44/en/docs/user_manual/>
426
+ - **PyQGIS 速查表(3.44):** <https://docs.qgis.org/3.44/en/docs/pyqgis_developer_cookbook/cheat_sheet.html>
427
+
428
+ > **注意:** `docs.qgis.org/4.2/...` 目前会 302 跳到 `/testing/`,4.2 的 cookbook 与用户手册尚未定稿;查阅 4.2 类与方法签名以 <https://qgis.org/pyqgis/4.2/> 为准。
@@ -1,5 +1,11 @@
1
1
  # PyQGIS Processing, Rendering and Workflows Reference
2
2
 
3
+ ## Contents
4
+
5
+ - Processing 算法调用
6
+ - 地图渲染与导出
7
+ - 典型工作流示例
8
+
3
9
  > 这是 [../SKILL.md](../SKILL.md) 的补充文件,收录 Processing 算法调用、地图渲染/导出与典型工作流示例。
4
10
 
5
11
  ---
@@ -1,5 +1,11 @@
1
1
  # PyQGIS Vector and Raster Layer Operations Reference
2
2
 
3
+ ## Contents
4
+
5
+ - 矢量图层操作
6
+ - 栅格图层操作
7
+ - 几何操作
8
+
3
9
  > 这是 [../SKILL.md](../SKILL.md) 的补充文件,收录矢量/栅格图层操作的完整 API 与示例。
4
10
 
5
11
  ---
@@ -1,17 +1,10 @@
1
1
  ---
2
2
  name: qgis-process
3
3
  description: "Use when running QGIS geoprocessing headless via qgis_process — native:buffer / native:reprojectlayer / native:clip, qgis_process list / help --json / run --json, .model3 models and .py scripts, batch CI pipelines, or debugging \"Algorithm ... not found!\"; includes QT_QPA_PLATFORM=offscreen and the qgis/qgis images (stable 4.2, ltr 3.44)."
4
- tags:
5
- - cli
6
- - qgis
7
- - processing
8
- - raster
9
- - automation
10
- - batch
11
- - ci-cd
12
- - json
13
- - workflow
14
- - shell
4
+ license: MIT
5
+ metadata:
6
+ category: gis
7
+ tags: "cli, qgis, processing, raster, automation, batch, ci-cd, json, workflow, shell"
15
8
  ---
16
9
 
17
10
  > **项目地址:** <https://github.com/qgis/QGIS>
@@ -20,7 +13,7 @@ tags:
20
13
  >
21
14
  > **在线文档:** <https://docs.qgis.org/4.2/en/docs/user_manual/processing/standalone.html>
22
15
  >
23
- > **最新版本:** QGIS 4.2.3;3.44 LTR 最新 3.44.15(截至2026-10,GitHub Releases;`qgis_process` 自 QGIS 3.16 起可用)
16
+ > **最新版本:** QGIS 4.2.3;3.44 LTR 最新 3.44.15(截至 2026-11,[GitHub Releases](https://github.com/qgis/QGIS/releases)、[下载页](https://qgis.org/download/);`qgis_process` 自 QGIS 3.16 起可用)
24
17
  >
25
18
  > **许可证:** GPL-2.0+
26
19
 
@@ -300,17 +293,70 @@ qgis_process run /path/to/my_script.py -- INPUT=data.shp OUTPUT=result.shp
300
293
 
301
294
  ---
302
295
 
303
- > 常用内置算法速查、参数类型参考与典型工作流示例见 [reference/algorithm-cheatsheet.md](reference/algorithm-cheatsheet.md)
296
+ > 常用内置算法速查与参数类型参考见 [reference/algorithm-cheatsheet.md](reference/algorithm-cheatsheet.md)
304
297
 
305
- ## DeepSeek Harness 使用建议
298
+ ## 典型工作流
306
299
 
307
- - **加载与引用**:用 `skill("qgis-process")` 加载(用户也可输入 `/qgis-process`);`reference/algorithm-cheatsheet.md` 按需 `read`,但算法参数一律以 `qgis_process help <id> --json` 的实时输出为准;技能目录只读,输出数据写会话工作区。
308
- - **执行环境**:命令交给 dsh 的 shell 工具(Windows 用 `pwsh`;仅暴露 `run_code` 的会话在 `tools.pwsh` 中执行)。Windows 下 `qgis_process` 在 `C:\Program Files\QGIS 4.2\bin`(LTR 为 `C:\Program Files\QGIS 3.44\bin`)或 OSGeo4W Shell 里;PowerShell 设 `$env:QT_QPA_PLATFORM = "offscreen"`,不要照抄 `export`。
309
- - **先探测版本**:`qgis_process --version`(QGIS 4.2.3 或 LTR 3.44.15)、`qgis_process list`;低于 3.16 没有 `qgis_process`,只能改用 PyQGIS 脚本;`--no-python`、`--skip-loading-plugins` 可显著加快启动。
310
- - **验证产物**:`run ... --json` 里的 `results.OUTPUT` 是实际写出的绝对路径,再用 `ogrinfo -so`(矢量)或 `gdalinfo -json`(栅格)核对要素数、CRS、范围;日志中出现 `returned non-zero` 说明算法内部失败,不要只看进程退出码。
311
- - **参数约定**:`--` 之后的参数不带前导 `--`;枚举传数字索引(`help --json` 里的 `available_options` 是映射表);多值参数重复同一键(`LAYERS=a.shp LAYERS=b.shp`);路径含空格或中文时加引号,尽量用绝对路径。
312
- - **常见报错**:`Algorithm <id> not found!` 先查 provider 前缀(`native:`、`gdal:`、`grass:`),`The following mandatory parameters were not specified` 回看 `help --json`,`requires a QGIS project to execute` 补 `--project_path`。
313
- - **安全与权限**:`OUTPUT=` 指向已有文件会被覆盖;`--project_path` 会加载项目内的数据源与凭证,注意不要把含密码的项目传给外部环境;启动 Docker 或安装 QGIS 前先征得用户同意,长任务放后台作业。
300
+ 目标:把 `data/points.shp` 做 50 m 缓冲区写入 GeoPackage,并在 CI 中批量重复同一流程。
301
+
302
+ ### 1. 先用 help 确认参数,不要凭记忆
303
+
304
+ ```bash
305
+ qgis_process help native:buffer --json > buffer-help.json
306
+ ```
307
+
308
+ 读取 `parameters` 中 `INPUT` / `DISTANCE` / `SEGMENTS` / `OUTPUT` 的名称与类型;`DISTANCE` 是 `distance` 类型,单位取图层 CRS 单位(投影坐标系下即米,地理坐标系下是度,极易算错)。
309
+
310
+ ### 2. 运行算法写出 GPKG
311
+
312
+ ```bash
313
+ qgis_process run native:buffer --json -- \
314
+ INPUT=data/points.shp \
315
+ DISTANCE=50 \
316
+ SEGMENTS=8 \
317
+ DISSOLVE=false \
318
+ OUTPUT=out/points_buffer_50m.gpkg
319
+ ```
320
+
321
+ `results.OUTPUT` 是实际写出的绝对路径,用它决定后续校验对象,不要自己拼路径。
322
+
323
+ ### 3. 校验产物
324
+
325
+ ```bash
326
+ ogrinfo -so out/points_buffer_50m.gpkg points_buffer_50m
327
+ ```
328
+
329
+ 核对要素数、CRS、几何类型;GPKG 内图层名默认取输出文件名(去扩展名)。`log` 里出现 `returned non-zero` 时即使进程退出码为 0 也算失败。
330
+
331
+ ### 4. 批量循环(CI 脚本)
332
+
333
+ ```bash
334
+ mkdir -p out
335
+ for f in data/*.shp; do
336
+ base=$(basename "$f" .shp)
337
+ qgis_process run native:buffer --json -- \
338
+ INPUT="$f" DISTANCE=50 OUTPUT="out/${base}_buffer.gpkg" \
339
+ || { echo "FAILED: $f" >&2; exit 1; }
340
+ done
341
+ ```
342
+
343
+ 每次 `run` 都会新起一个 QGIS 进程(数秒开销);文件量大时改用 PyQGIS 的 `processing.run()` 在单进程内循环,见 [../pyqgis/SKILL.md](../pyqgis/SKILL.md)。
344
+
345
+ 输入 `data/points.shp` → `native:buffer` → `out/points_buffer_50m.gpkg` → `ogrinfo` 校验,构成 qgis_process 批处理的最小闭环。
346
+
347
+ ## 常见问题
348
+
349
+ | 问题 | 解决方案 |
350
+ |------|---------|
351
+ | 提示 `command not found: qgis_process` | 将 QGIS 的 `bin` 目录加入 `PATH`;Windows 下改用 OSGeo4W Shell 运行 |
352
+ | 无显示器的服务器上崩溃或卡住 | 设置环境变量 `QT_QPA_PLATFORM=offscreen` |
353
+ | `Algorithm <id> not found!` | 用 `qgis_process list` 确认算法 ID 与 Provider 前缀(如 `native:`、`gdal:`) |
354
+ | 缺少必填参数 | 先用 `qgis_process help <id> --json` 查看参数名、类型与默认值 |
355
+ | 枚举参数报错 | 枚举值需传数字索引,`help --json` 中的 `available_options` 提供索引映射 |
356
+ | 多值参数只生效一项 | 在 `--` 之后多次指定同一参数(如 `LAYERS=a.shp LAYERS=b.shp`) |
357
+ | 路径含空格或中文时报错 | 使用绝对路径并对参数值加引号 |
358
+ | 启动速度慢 | 不需要 Python/插件时添加 `--no-python` 与 `--skip-loading-plugins` |
359
+ | 模型/脚本或算法不可用 | 报 `File <path> is not a valid Processing model!` / `... is not a valid Processing script!` / `not available for use outside of the QGIS desktop application` 时,改用 QGIS 桌面或 PyQGIS 脚本 |
314
360
 
315
361
  ---
316
362
 
@@ -329,19 +375,15 @@ qgis_process run /path/to/my_script.py -- INPUT=data.shp OUTPUT=result.shp
329
375
 
330
376
  ---
331
377
 
332
- ## 常见问题
378
+ ## AI 使用建议
333
379
 
334
- | 问题 | 解决方案 |
335
- |------|---------|
336
- | 提示 `command not found: qgis_process` | 将 QGIS 的 `bin` 目录加入 `PATH`;Windows 下改用 OSGeo4W Shell 运行 |
337
- | 无显示器的服务器上崩溃或卡住 | 设置环境变量 `QT_QPA_PLATFORM=offscreen` |
338
- | `Algorithm <id> not found!` | 用 `qgis_process list` 确认算法 ID 与 Provider 前缀(如 `native:`、`gdal:`) |
339
- | 缺少必填参数 | 先用 `qgis_process help <id> --json` 查看参数名、类型与默认值 |
340
- | 枚举参数报错 | 枚举值需传数字索引,`help --json` 中的 `available_options` 提供索引映射 |
341
- | 多值参数只生效一项 | 在 `--` 之后多次指定同一参数(如 `LAYERS=a.shp LAYERS=b.shp`) |
342
- | 路径含空格或中文时报错 | 使用绝对路径并对参数值加引号 |
343
- | 启动速度慢 | 不需要 Python/插件时添加 `--no-python` 与 `--skip-loading-plugins` |
344
- | 模型/脚本或算法不可用 | 报 `File <path> is not a valid Processing model!` / `... is not a valid Processing script!` / `not available for use outside of the QGIS desktop application` 时,改用 QGIS 桌面或 PyQGIS 脚本 |
380
+ - **本技能的组织**:主文件给高频用法,完整参数表与高级示例在 `reference/algorithm-cheatsheet.md`,需要时再展开;示例工程与生成的数据写到工作目录,不要改动技能目录本身。
381
+ - **执行环境**:命令在终端 / shell 中执行(Windows 用 PowerShell)。Windows 下 `qgis_process` 在 `C:\Program Files\QGIS 4.2\bin`(LTR 为 `C:\Program Files\QGIS 3.44\bin`)或 OSGeo4W Shell 里;PowerShell 设 `$env:QT_QPA_PLATFORM = "offscreen"`,不要照抄 `export`。
382
+ - **先探测版本**:`qgis_process --version`(QGIS 4.2.3 或 LTR 3.44.15)、`qgis_process list`;低于 3.16 没有 `qgis_process`,只能改用 PyQGIS 脚本;`--no-python`、`--skip-loading-plugins` 可显著加快启动。
383
+ - **验证产物**:`run ... --json` 里的 `results.OUTPUT` 是实际写出的绝对路径,再用 `ogrinfo -so`(矢量)或 `gdalinfo -json`(栅格)核对要素数、CRS、范围;日志中出现 `returned non-zero` 说明算法内部失败,不要只看进程退出码。
384
+ - **参数约定**:`--` 之后的参数不带前导 `--`;枚举传数字索引(`help --json` 里的 `available_options` 是映射表);多值参数重复同一键(`LAYERS=a.shp LAYERS=b.shp`);路径含空格或中文时加引号,尽量用绝对路径。
385
+ - **常见报错**:`Algorithm <id> not found!` 先查 provider 前缀(`native:`、`gdal:`、`grass:`),`The following mandatory parameters were not specified` 回看 `help --json`,`requires a QGIS project to execute` 补 `--project_path`。
386
+ - **安全与权限**:`OUTPUT=` 指向已有文件会被覆盖;`--project_path` 会加载项目内的数据源与凭证,注意不要把含密码的项目传给外部环境;启动 Docker 或安装 QGIS 前先征得用户同意,长任务放后台运行。
345
387
 
346
388
  ---
347
389
 
@@ -1,5 +1,11 @@
1
1
  # QGIS Process Algorithm Cheatsheet Reference
2
2
 
3
+ ## Contents
4
+
5
+ - 常用内置算法速查
6
+ - 参数类型参考
7
+ - 典型工作流示例
8
+
3
9
  Built-in algorithm cheatsheet, parameter types and typical workflow examples split from SKILL.md.
4
10
 
5
11
  ---