@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.
- package/CHANGELOG.md +95 -0
- package/README.md +68 -28
- package/THIRD_PARTY_NOTICES.md +9 -0
- package/adaptations/brutile.md +8 -0
- package/adaptations/cesiumjs.md +8 -0
- package/adaptations/common.md +19 -0
- package/adaptations/deck-gl.md +8 -0
- package/adaptations/duckdb-spatial.md +8 -0
- package/adaptations/gdal-api.md +8 -0
- package/adaptations/gdal.md +8 -0
- package/adaptations/geolibre.md +8 -0
- package/adaptations/geometry-api-java.md +8 -0
- package/adaptations/geometry-api-net.md +8 -0
- package/adaptations/geonode.md +8 -0
- package/adaptations/geopandas.md +8 -0
- package/adaptations/geopipe-agent.md +8 -0
- package/adaptations/geoserver-cloud.md +8 -0
- package/adaptations/geoserver-rest-api.md +8 -0
- package/adaptations/geoserver.md +8 -0
- package/adaptations/geotools.md +8 -0
- package/adaptations/grass-gis.md +8 -0
- package/adaptations/jts.md +8 -0
- package/adaptations/kepler-gl.md +8 -0
- package/adaptations/leaflet.md +8 -0
- package/adaptations/mapbox-gl-js.md +8 -0
- package/adaptations/mapserver.md +8 -0
- package/adaptations/mapsui.md +8 -0
- package/adaptations/nettopologysuite.md +8 -0
- package/adaptations/opengis-all.md +9 -0
- package/adaptations/opengis-daf.md +9 -0
- package/adaptations/opengis-utils-for-java.md +8 -0
- package/adaptations/opengis-utils-for-net.md +8 -0
- package/adaptations/openlayers.md +8 -0
- package/adaptations/pdal.md +8 -0
- package/adaptations/postgis.md +8 -0
- package/adaptations/proj.md +8 -0
- package/adaptations/projnet4geoapi.md +8 -0
- package/adaptations/pyqgis.md +8 -0
- package/adaptations/qgis-process.md +8 -0
- package/adaptations/qgis-server.md +8 -0
- package/adaptations/shapely.md +8 -0
- package/adaptations/sharpmap.md +8 -0
- package/adaptations/spatialite.md +8 -0
- package/adaptations/whitebox-tools.md +8 -0
- package/assets/brutile/SKILL.md +283 -0
- package/assets/cesiumjs/SKILL.md +81 -35
- package/assets/deck-gl/SKILL.md +26 -34
- package/assets/duckdb-spatial/SKILL.md +363 -0
- package/assets/gdal/SKILL.md +55 -33
- package/assets/gdal/reference/raster-tools.md +14 -0
- package/assets/gdal/reference/vector-tools.md +5 -0
- package/assets/gdal-api/SKILL.md +12 -18
- package/assets/gdal-api/reference/raster-api.md +7 -0
- package/assets/gdal-api/reference/vector-api.md +9 -0
- package/assets/geolibre/SKILL.md +357 -0
- package/assets/geometry-api-java/SKILL.md +10 -16
- package/assets/geometry-api-net/SKILL.md +70 -32
- package/assets/geometry-api-net/reference/geometry-types.md +5 -0
- package/assets/geonode/SKILL.md +340 -0
- package/assets/geopandas/SKILL.md +21 -24
- package/assets/geopandas/reference/core-api.md +4 -0
- package/assets/geopipe-agent/SKILL.md +29 -31
- package/assets/geopipe-agent/reference/steps-reference.md +12 -0
- package/assets/geopipe-agent/reference/workflows.md +8 -0
- package/assets/geoserver/SKILL.md +10 -15
- package/assets/geoserver-cloud/SKILL.md +25 -33
- package/assets/geoserver-rest-api/SKILL.md +17 -19
- package/assets/geoserver-rest-api/reference/endpoints.md +16 -0
- package/assets/geotools/SKILL.md +12 -17
- package/assets/geotools/reference/raster-rendering.md +5 -0
- package/assets/geotools/reference/vector-io.md +7 -0
- package/assets/grass-gis/SKILL.md +26 -33
- package/assets/jts/SKILL.md +12 -16
- package/assets/jts/reference/geometry-operations.md +13 -0
- package/assets/kepler-gl/SKILL.md +306 -0
- package/assets/leaflet/SKILL.md +58 -40
- package/assets/mapbox-gl-js/SKILL.md +26 -33
- package/assets/mapserver/SKILL.md +21 -29
- package/assets/mapsui/SKILL.md +109 -63
- package/assets/nettopologysuite/SKILL.md +96 -31
- package/assets/opengis-all/SKILL.md +91 -289
- package/assets/opengis-all/reference/data-stages.md +269 -4
- package/assets/opengis-all/reference/workflow-cheatsheets.md +7 -0
- package/assets/opengis-daf/SKILL.md +10 -17
- package/assets/opengis-utils-for-java/SKILL.md +58 -49
- package/assets/opengis-utils-for-java/reference/common-tasks.md +16 -12
- package/assets/opengis-utils-for-net/SKILL.md +109 -48
- package/assets/opengis-utils-for-net/reference/code-patterns.md +15 -11
- package/assets/opengis-utils-for-net/reference/util-classes.md +35 -26
- package/assets/openlayers/SKILL.md +81 -28
- package/assets/pdal/SKILL.md +25 -27
- package/assets/postgis/SKILL.md +80 -35
- package/assets/proj/SKILL.md +32 -41
- package/assets/projnet4geoapi/SKILL.md +293 -0
- package/assets/pyqgis/SKILL.md +33 -30
- package/assets/pyqgis/reference/processing-rendering.md +6 -0
- package/assets/pyqgis/reference/vector-raster-layers.md +6 -0
- package/assets/qgis-process/SKILL.md +75 -33
- package/assets/qgis-process/reference/algorithm-cheatsheet.md +6 -0
- package/assets/qgis-server/SKILL.md +25 -31
- package/assets/shapely/SKILL.md +136 -84
- package/assets/shapely/reference/operations-reference.md +12 -0
- package/assets/sharpmap/SKILL.md +97 -60
- package/assets/spatialite/SKILL.md +358 -0
- package/assets/whitebox-tools/SKILL.md +262 -0
- package/lib/adaptations.d.ts +53 -0
- package/lib/adaptations.js +343 -0
- package/lib/catalog.d.ts +7 -1
- package/lib/catalog.js +9 -1
- package/lib/index.d.ts +10 -1
- package/lib/index.js +34 -3
- package/lib/skill-file.d.ts +12 -0
- package/lib/skill-file.js +133 -18
- package/locale/en.json +1 -1
- package/locale/zh.json +1 -1
- package/package.json +12 -2
- package/upstream.json +73 -57
|
@@ -1,28 +1,22 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: opengis-all
|
|
3
3
|
description: "Use when navigating end-to-end GIS workflows — GDAL CLI/API (ogr2ogr, gdalwarp, gdal_calc.py), qgis_process and PyQGIS analysis, GeoServer REST publishing, and OpenLayers/CesiumJS visualization. One-stop index covering the complete open-source GIS data pipeline."
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
- workflow
|
|
9
|
-
- fullstack
|
|
10
|
-
- gdal
|
|
11
|
-
- qgis
|
|
12
|
-
- geoserver
|
|
13
|
-
- pyqgis
|
|
14
|
-
- tutorial
|
|
4
|
+
license: MIT
|
|
5
|
+
metadata:
|
|
6
|
+
category: gis
|
|
7
|
+
tags: "gis, entrypoint, workflow, fullstack, gdal, qgis, geoserver, pyqgis, tutorial"
|
|
15
8
|
---
|
|
16
9
|
|
|
17
10
|
> **涵盖工具与项目:**
|
|
18
11
|
>
|
|
19
|
-
> | 工具/接口 | 项目地址 | 文档 | 许可证 |
|
|
20
|
-
>
|
|
21
|
-
> | GDAL 命令行 | <https://github.com/OSGeo/gdal> | <https://gdal.org/en/latest/programs/> | MIT |
|
|
22
|
-
> | GDAL API (C++/Python/Java/C#) | <https://github.com/OSGeo/gdal> | <https://gdal.org/en/stable/api/index.html> | MIT |
|
|
23
|
-
> | qgis_process | <https://github.com/qgis/QGIS> | <https://docs.qgis.org/3.44/en/docs/user_manual/processing/standalone.html> | GPL-2.0+ |
|
|
24
|
-
> | PyQGIS | <https://github.com/qgis/QGIS> | <https://docs.qgis.org/3.44/en/docs/pyqgis_developer_cookbook/> | GPL-2.0+ |
|
|
25
|
-
> | GeoServer REST API | <https://github.com/geoserver/geoserver> | <https://docs.geoserver.org/latest/en/user/rest/index.html> | GPL-2.0+ |
|
|
12
|
+
> | 工具/接口 | 最新版本(截至 2026-11) | 项目地址 | 文档 | 许可证 |
|
|
13
|
+
> |-----------|------------------------|----------|------|--------|
|
|
14
|
+
> | GDAL 命令行 | 3.13.3 | <https://github.com/OSGeo/gdal> | <https://gdal.org/en/latest/programs/> | MIT |
|
|
15
|
+
> | GDAL API (C++/Python/Java/C#) | 3.13.3 | <https://github.com/OSGeo/gdal> | <https://gdal.org/en/stable/api/index.html> | MIT |
|
|
16
|
+
> | QGIS / qgis_process | 4.2.3(LTR 3.44.15) | <https://github.com/qgis/QGIS> | <https://docs.qgis.org/3.44/en/docs/user_manual/processing/standalone.html> | GPL-2.0+ |
|
|
17
|
+
> | PyQGIS | 4.2.3(LTR 3.44.15) | <https://github.com/qgis/QGIS> | <https://docs.qgis.org/3.44/en/docs/pyqgis_developer_cookbook/> | GPL-2.0+ |
|
|
18
|
+
> | GeoServer REST API | 3.0.2 | <https://github.com/geoserver/geoserver> | <https://docs.geoserver.org/latest/en/user/rest/index.html> | GPL-2.0+ |
|
|
19
|
+
> | OpenLayers / CesiumJS(前端) | ol 10.11.0 / Cesium 1.147.0 | <https://github.com/openlayers/openlayers> | <https://openlayers.org/doc/> | BSD-2-Clause / Apache-2.0 |
|
|
26
20
|
|
|
27
21
|
## 概述
|
|
28
22
|
|
|
@@ -76,7 +70,7 @@ python3 -c "from osgeo import gdal; print(gdal.VersionInfo())"
|
|
|
76
70
|
### QGIS(qgis_process + PyQGIS)
|
|
77
71
|
|
|
78
72
|
```bash
|
|
79
|
-
# 安装 QGIS 3.44 LTR
|
|
73
|
+
# 安装 QGIS 4.2.3 或 3.44 LTR(qgis_process 从 3.16 开始可用)
|
|
80
74
|
# Ubuntu
|
|
81
75
|
apt-get install qgis qgis-plugin-grass
|
|
82
76
|
|
|
@@ -101,7 +95,7 @@ curl -u admin:geoserver "http://localhost:8080/geoserver/rest/about/version.json
|
|
|
101
95
|
|
|
102
96
|
---
|
|
103
97
|
|
|
104
|
-
>
|
|
98
|
+
> 阶段一(数据获取与信息查询)、阶段二(数据处理与转换)、阶段三(空间分析)的完整操作手册见 [reference/data-stages.md](reference/data-stages.md)
|
|
105
99
|
|
|
106
100
|
## 核心 API 与命令速查
|
|
107
101
|
|
|
@@ -119,278 +113,82 @@ curl -u admin:geoserver "http://localhost:8080/geoserver/rest/about/version.json
|
|
|
119
113
|
|
|
120
114
|
---
|
|
121
115
|
|
|
122
|
-
##
|
|
123
|
-
|
|
124
|
-
### 3.1 缓冲区分析
|
|
125
|
-
|
|
126
|
-
```bash
|
|
127
|
-
# qgis_process
|
|
128
|
-
qgis_process run native:buffer -- \
|
|
129
|
-
INPUT=points.shp DISTANCE=1000 SEGMENTS=16 OUTPUT=buffered.gpkg
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
```python
|
|
133
|
-
# PyQGIS (processing)
|
|
134
|
-
result = processing.run("native:buffer", {
|
|
135
|
-
'INPUT': '/data/roads.shp',
|
|
136
|
-
'DISTANCE': 50,
|
|
137
|
-
'SEGMENTS': 10,
|
|
138
|
-
'DISSOLVE': False,
|
|
139
|
-
'OUTPUT': '/data/roads_buffer.shp'
|
|
140
|
-
})
|
|
141
|
-
```
|
|
116
|
+
## 阶段三:空间分析(速查)
|
|
142
117
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
### 3.2 叠加分析(交集/联合/差集)
|
|
157
|
-
|
|
158
|
-
```bash
|
|
159
|
-
# qgis_process — 交集
|
|
160
|
-
qgis_process run native:intersection -- \
|
|
161
|
-
INPUT=layer1.shp OVERLAY=layer2.shp OUTPUT=intersection.shp
|
|
162
|
-
|
|
163
|
-
# qgis_process — 联合
|
|
164
|
-
qgis_process run native:union -- \
|
|
165
|
-
INPUT=layer1.shp OVERLAY=layer2.shp OUTPUT=union.shp
|
|
166
|
-
|
|
167
|
-
# qgis_process — 差集
|
|
168
|
-
qgis_process run native:difference -- \
|
|
169
|
-
INPUT=layer1.shp OVERLAY=layer2.shp OUTPUT=difference.shp
|
|
170
|
-
```
|
|
171
|
-
|
|
172
|
-
```python
|
|
173
|
-
# PyQGIS
|
|
174
|
-
result = processing.run("native:intersection", {
|
|
175
|
-
'INPUT': layer1, 'OVERLAY': layer2, 'OUTPUT': 'memory:intersected'
|
|
176
|
-
})
|
|
177
|
-
```
|
|
178
|
-
|
|
179
|
-
```python
|
|
180
|
-
# PyQGIS 几何级别操作
|
|
181
|
-
intersection = geom1.intersection(geom2)
|
|
182
|
-
union = geom1.combine(geom2)
|
|
183
|
-
difference = geom1.difference(geom2)
|
|
184
|
-
sym_diff = geom1.symDifference(geom2)
|
|
185
|
-
```
|
|
186
|
-
|
|
187
|
-
```python
|
|
188
|
-
# GDAL OGR 几何级别操作
|
|
189
|
-
inter = polygon.Intersection(pt)
|
|
190
|
-
united = polygon.Union(pt)
|
|
191
|
-
diff = polygon.Difference(pt)
|
|
192
|
-
```
|
|
193
|
-
|
|
194
|
-
### 3.3 融合(Dissolve)
|
|
195
|
-
|
|
196
|
-
```bash
|
|
197
|
-
# qgis_process
|
|
198
|
-
qgis_process run native:dissolve -- \
|
|
199
|
-
INPUT=polygons.shp FIELD=type OUTPUT=dissolved.gpkg
|
|
200
|
-
```
|
|
201
|
-
|
|
202
|
-
```python
|
|
203
|
-
# PyQGIS
|
|
204
|
-
result = processing.run("native:dissolve", {
|
|
205
|
-
'INPUT': '/data/polygons.shp',
|
|
206
|
-
'FIELD': ['type'],
|
|
207
|
-
'OUTPUT': '/data/dissolved.gpkg'
|
|
208
|
-
})
|
|
209
|
-
```
|
|
210
|
-
|
|
211
|
-
### 3.4 空间连接
|
|
212
|
-
|
|
213
|
-
```bash
|
|
214
|
-
# qgis_process — 按位置连接属性
|
|
215
|
-
qgis_process run native:joinattributesbylocation -- \
|
|
216
|
-
INPUT=points.shp JOIN=polygons.shp PREDICATE=0 OUTPUT=joined.shp
|
|
217
|
-
```
|
|
218
|
-
|
|
219
|
-
```python
|
|
220
|
-
# PyQGIS
|
|
221
|
-
result = processing.run("native:joinattributesbylocation", {
|
|
222
|
-
'INPUT': points_layer,
|
|
223
|
-
'JOIN': polygons_layer,
|
|
224
|
-
'PREDICATE': [0], # 0=相交
|
|
225
|
-
'METHOD': 0, # 0=一对一
|
|
226
|
-
'OUTPUT': 'memory:joined'
|
|
227
|
-
})
|
|
228
|
-
```
|
|
229
|
-
|
|
230
|
-
### 3.5 栅格计算(波段运算)
|
|
231
|
-
|
|
232
|
-
```bash
|
|
233
|
-
# NDVI 计算
|
|
234
|
-
gdal_calc.py -A nir.tif -B red.tif \
|
|
235
|
-
--calc="(A-B)/(A+B)" --outfile=ndvi.tif
|
|
236
|
-
|
|
237
|
-
# 栅格掩膜
|
|
238
|
-
gdal_calc.py -A input.tif --calc="A*(A>100)" \
|
|
239
|
-
--outfile=masked.tif --NoDataValue=0
|
|
240
|
-
|
|
241
|
-
# 两个栅格平均
|
|
242
|
-
gdal_calc.py -A input1.tif -B input2.tif \
|
|
243
|
-
--calc="(A+B)/2" --outfile=mean.tif
|
|
244
|
-
```
|
|
245
|
-
|
|
246
|
-
### 3.6 DEM 分析
|
|
247
|
-
|
|
248
|
-
```bash
|
|
249
|
-
# 等值线提取
|
|
250
|
-
gdal_contour -a elevation dem.tif contours.shp -i 10
|
|
251
|
-
|
|
252
|
-
# qgis_process — 坡度分析
|
|
253
|
-
qgis_process run gdal:slope -- INPUT=dem.tif OUTPUT=slope.tif
|
|
254
|
-
|
|
255
|
-
# qgis_process — 坡向分析
|
|
256
|
-
qgis_process run gdal:aspect -- INPUT=dem.tif OUTPUT=aspect.tif
|
|
257
|
-
|
|
258
|
-
# qgis_process — 山体阴影
|
|
259
|
-
qgis_process run gdal:hillshade -- INPUT=dem.tif OUTPUT=hillshade.tif
|
|
260
|
-
```
|
|
261
|
-
|
|
262
|
-
```python
|
|
263
|
-
# PyQGIS — 坡度分析
|
|
264
|
-
result = processing.run("gdal:slope", {
|
|
265
|
-
'INPUT': '/data/dem.tif',
|
|
266
|
-
'OUTPUT': '/data/slope.tif'
|
|
267
|
-
})
|
|
268
|
-
```
|
|
118
|
+
| 任务 | 命令入口 |
|
|
119
|
+
|------|----------|
|
|
120
|
+
| 缓冲区 | `qgis_process run native:buffer -- INPUT=... DISTANCE=... OUTPUT=...` |
|
|
121
|
+
| 交集/联合/差集 | `native:intersection / native:union / native:difference` |
|
|
122
|
+
| 融合 | `native:dissolve -- FIELD=...` |
|
|
123
|
+
| 空间连接 | `native:joinattributesbylocation -- PREDICATE=0` |
|
|
124
|
+
| 按属性/位置提取 | `native:extractbyattribute / native:extractbylocation` |
|
|
125
|
+
| 栅格波段运算 | `gdal_calc.py -A nir.tif -B red.tif --calc="(A-B)/(A+B)"` |
|
|
126
|
+
| DEM 分析 | `gdal_contour -i 10 / qgis_process run gdal:slope|aspect|hillshade` |
|
|
127
|
+
| 插值成 DEM | `gdal_grid -a invdist:power=2:zfield=Z` |
|
|
128
|
+
| 栅格矢量互转 | `gdal_polygonize.py / qgis_process run gdal:rasterize` |
|
|
129
|
+
| 地图渲染导出 | `PyQGIS QgsMapRendererSequentialJob / QgsLayoutExporter` |
|
|
269
130
|
|
|
270
|
-
|
|
131
|
+
> 完整的 3.1-3.10 逐项示例(qgis_process、PyQGIS、GDAL Python API 三种写法)见 [reference/data-stages.md](reference/data-stages.md)。
|
|
271
132
|
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
gdal_grid -a invdist:power=2:smoothing=0 \
|
|
275
|
-
-zfield Z input_points.shp output_dem.tif
|
|
276
|
-
|
|
277
|
-
# 指定输出范围和分辨率
|
|
278
|
-
gdal_grid -outsize 512 512 -tr 10 10 \
|
|
279
|
-
-a average input_points.shp output_dem.tif
|
|
280
|
-
```
|
|
281
|
-
|
|
282
|
-
### 3.8 栅格矢量互转
|
|
133
|
+
> 阶段四(发布 GIS 地图服务)的完整 GeoServer REST 操作见 [reference/data-stages.md](reference/data-stages.md)
|
|
134
|
+
> 端到端工作流示例、内置算法速查、GDAL 命令速查、数据格式与环境变量见 [reference/workflow-cheatsheets.md](reference/workflow-cheatsheets.md)
|
|
283
135
|
|
|
284
|
-
|
|
285
|
-
# 栅格转矢量(多边形化)
|
|
286
|
-
gdal_polygonize.py input.tif output.shp
|
|
136
|
+
## 典型工作流
|
|
287
137
|
|
|
288
|
-
|
|
289
|
-
qgis_process run gdal:polygonize -- INPUT=input.tif OUTPUT=output.shp
|
|
138
|
+
### 端到端:Shapefile → 缓冲分析 → GeoServer 发布 → Web 预览
|
|
290
139
|
|
|
291
|
-
|
|
292
|
-
qgis_process run gdal:rasterize -- \
|
|
293
|
-
INPUT=input.shp FIELD=value OUTPUT=output.tif
|
|
294
|
-
```
|
|
140
|
+
输入 `data/roads.shp`(EPSG:4326),输出 `http://localhost:8080/geoserver/wms` 上可用的图层 `demo:roads_buffer`。
|
|
295
141
|
|
|
296
|
-
|
|
142
|
+
1. **探索数据**:`ogrinfo -so -al data/roads.shp` 确认要素数与 CRS
|
|
143
|
+
2. **统一格式与坐标系**:`ogr2ogr -t_srs EPSG:3857 roads_3857.gpkg data/roads.shp`
|
|
144
|
+
3. **空间分析**:`qgis_process run native:buffer -- INPUT=roads_3857.gpkg DISTANCE=500 OUTPUT=roads_buffer.gpkg`
|
|
145
|
+
4. **验证结果**:`ogrinfo -so roads_buffer.gpkg roads_buffer` 核对方框与要素数
|
|
146
|
+
5. **发布服务**:GeoServer REST 建工作空间 → 上传 GeoPackage → 发布图层
|
|
147
|
+
6. **前端预览**:OpenLayers `TileWMS` 指向 `/geoserver/wms`,`LAYERS: 'demo:roads_buffer'`
|
|
297
148
|
|
|
298
149
|
```bash
|
|
299
|
-
#
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
# 属性过滤
|
|
319
|
-
request = QgsFeatureRequest().setFilterExpression('"population" > 10000')
|
|
320
|
-
for feature in layer.getFeatures(request):
|
|
321
|
-
print(feature["name"])
|
|
322
|
-
|
|
323
|
-
# 空间范围过滤
|
|
324
|
-
rect = QgsRectangle(116.0, 39.0, 117.0, 40.0)
|
|
325
|
-
request = QgsFeatureRequest().setFilterRect(rect)
|
|
326
|
-
for feature in layer.getFeatures(request):
|
|
327
|
-
print(feature.id())
|
|
328
|
-
```
|
|
329
|
-
|
|
330
|
-
```python
|
|
331
|
-
# GDAL Python API — 空间过滤 + 属性过滤
|
|
332
|
-
from osgeo import ogr
|
|
333
|
-
|
|
334
|
-
ds = ogr.Open("input.shp")
|
|
335
|
-
layer = ds.GetLayer(0)
|
|
336
|
-
layer.SetSpatialFilterRect(116.0, 39.5, 117.0, 40.5)
|
|
337
|
-
layer.SetAttributeFilter("POPULATION > 1000000")
|
|
338
|
-
|
|
339
|
-
for feature in layer:
|
|
340
|
-
print(feature.GetField("NAME"))
|
|
341
|
-
ds = None
|
|
342
|
-
```
|
|
343
|
-
|
|
344
|
-
### 3.10 地图渲染与导出
|
|
345
|
-
|
|
346
|
-
```python
|
|
347
|
-
# PyQGIS — 渲染为 PNG
|
|
348
|
-
from qgis.core import QgsMapSettings, QgsMapRendererSequentialJob
|
|
349
|
-
from qgis.PyQt.QtCore import QSize
|
|
350
|
-
|
|
351
|
-
settings = QgsMapSettings()
|
|
352
|
-
settings.setLayers([layer])
|
|
353
|
-
settings.setDestinationCrs(layer.crs())
|
|
354
|
-
settings.setExtent(layer.extent())
|
|
355
|
-
settings.setOutputSize(QSize(1920, 1080))
|
|
356
|
-
|
|
357
|
-
job = QgsMapRendererSequentialJob(settings)
|
|
358
|
-
job.start()
|
|
359
|
-
job.waitForFinished()
|
|
360
|
-
job.renderedImage().save("/data/map_output.png")
|
|
150
|
+
# 1~4:本地分析与验证
|
|
151
|
+
ogrinfo -so -al data/roads.shp
|
|
152
|
+
ogr2ogr -t_srs EPSG:3857 roads_3857.gpkg data/roads.shp
|
|
153
|
+
QT_QPA_PLATFORM=offscreen qgis_process run native:buffer -- \
|
|
154
|
+
INPUT=roads_3857.gpkg DISTANCE=500 SEGMENTS=8 OUTPUT=roads_buffer.gpkg
|
|
155
|
+
ogrinfo -so roads_buffer.gpkg roads_buffer
|
|
156
|
+
|
|
157
|
+
# 5:发布(GeoServer 3.0.2,默认 admin/geoserver)
|
|
158
|
+
BASE=http://localhost:8080/geoserver/rest
|
|
159
|
+
curl -u admin:geoserver -X POST "$BASE/workspaces" \
|
|
160
|
+
-H 'Content-Type: application/json' \
|
|
161
|
+
-d '{"workspace":{"name":"demo"}}'
|
|
162
|
+
|
|
163
|
+
curl -u admin:geoserver -X PUT "$BASE/workspaces/demo/datastores/roads/file.gpkg?configure=all" \
|
|
164
|
+
-H 'Content-Type: application/geopackage+sqlite3' \
|
|
165
|
+
--data-binary @roads_buffer.gpkg
|
|
166
|
+
|
|
167
|
+
# 6:回读确认图层已发布
|
|
168
|
+
curl -u admin:geoserver "$BASE/layers/demo:roads_buffer.json"
|
|
361
169
|
```
|
|
362
170
|
|
|
363
|
-
```
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
171
|
+
```js
|
|
172
|
+
// 6:OpenLayers 前端预览
|
|
173
|
+
import Map from 'ol/Map.js';
|
|
174
|
+
import View from 'ol/View.js';
|
|
175
|
+
import TileLayer from 'ol/layer/Tile.js';
|
|
176
|
+
import TileWMS from 'ol/source/TileWMS.js';
|
|
177
|
+
|
|
178
|
+
new Map({
|
|
179
|
+
target: 'map',
|
|
180
|
+
layers: [new TileLayer({
|
|
181
|
+
source: new TileWMS({
|
|
182
|
+
url: 'http://localhost:8080/geoserver/wms',
|
|
183
|
+
params: { LAYERS: 'demo:roads_buffer', TILED: true }
|
|
184
|
+
})
|
|
185
|
+
})],
|
|
186
|
+
view: new View({ center: [12968000, 4863000], zoom: 12 })
|
|
187
|
+
});
|
|
379
188
|
```
|
|
380
189
|
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
> 阶段四(发布 GIS 地图服务)的完整 GeoServer REST 操作见 [reference/data-stages.md](reference/data-stages.md)
|
|
384
|
-
> 端到端工作流示例、内置算法速查、GDAL 命令速查、数据格式与环境变量见 [reference/workflow-cheatsheets.md](reference/workflow-cheatsheets.md)
|
|
385
|
-
|
|
386
|
-
## 典型工作流
|
|
190
|
+
**验收**:`curl -u admin:geoserver .../layers/demo:roads_buffer.json` 返回 200 且含 `"enabled": true`;前端地图能看到缓冲区图形。任一步失败都不要继续后续阶段——先修当前阶段的产物。
|
|
387
191
|
|
|
388
|
-
1. **探索数据**:`ogrinfo -json` / `gdalinfo -json` — 获取结构化元数据
|
|
389
|
-
2. **格式转换**:`ogr2ogr` / `gdal_translate` — 统一数据格式
|
|
390
|
-
3. **坐标统一**:`ogr2ogr -t_srs` / `gdalwarp -t_srs` — 统一坐标系
|
|
391
|
-
4. **空间分析**:`qgis_process run` / `processing.run()` — 执行分析算法
|
|
392
|
-
5. **结果验证**:`ogrinfo -json` / `gdalinfo -json` — 验证输出
|
|
393
|
-
6. **发布服务**:GeoServer REST API — 上传并发布地图服务
|
|
394
192
|
|
|
395
193
|
---
|
|
396
194
|
|
|
@@ -407,17 +205,6 @@ exporter.exportToPdf("/data/output.pdf", QgsLayoutExporter.PdfExportSettings())
|
|
|
407
205
|
|
|
408
206
|
---
|
|
409
207
|
|
|
410
|
-
## DeepSeek Harness 使用建议
|
|
411
|
-
|
|
412
|
-
- **加载与引用**:用 `skill("opengis-all")` 加载(用户也可输入 `/opengis-all`);本页是阶段索引,详细步骤在 `reference/data-stages.md` 与 `reference/workflow-cheatsheets.md`,按当前阶段 `read`,不要一次全读。
|
|
413
|
-
- **执行环境**:命令交给 dsh 的 shell 工具(Windows 用 `pwsh`;仅暴露 `run_code` 的会话在 `tools.pwsh` 中执行)。示例是 Linux/bash 写法,按平台改写 `apt`、`/tmp`、`export` 与反引号;Windows 路径加引号。
|
|
414
|
-
- **先探测工具链**:`gdalinfo --version`、`qgis_process --version`、`python3 -c "from osgeo import gdal; print(gdal.VersionInfo())"`、`curl -u admin:geoserver "http://localhost:8080/geoserver/rest/about/version.json"`;缺哪个阶段就加载相邻技能(如 `skill("gdal")`、`skill("qgis-process")`)。
|
|
415
|
-
- **分阶段交付**:每阶段产物落盘到工作区(GeoPackage/COG/GeoJSON),下一阶段只读取产物;先用 `ogrinfo -so`、`gdalinfo -json` 看摘要,不要把大文件或大段输出贴进上下文。
|
|
416
|
-
- **验证**:转换后重新打开结果核对 CRS、范围、要素数;发布后用 `curl` 回读 REST 资源或 `GetCapabilities`;无显示器环境设置 `QT_QPA_PLATFORM=offscreen`;`qgis_process` 参数先用 `qgis_process help <id> --json` 确认。
|
|
417
|
-
- **安全**:`gdal_edit.py`、覆盖输出、GeoServer `?recurse=true` 删除均不可逆;先备份并确认路径,安装 GDAL/QGIS、启动服务或使用数据库凭据前先征得用户同意。
|
|
418
|
-
|
|
419
|
-
---
|
|
420
|
-
|
|
421
208
|
## 常见问题
|
|
422
209
|
|
|
423
210
|
| 问题 | 解决 |
|
|
@@ -432,6 +219,17 @@ exporter.exportToPdf("/data/output.pdf", QgsLayoutExporter.PdfExportSettings())
|
|
|
432
219
|
|
|
433
220
|
---
|
|
434
221
|
|
|
222
|
+
## AI 使用建议
|
|
223
|
+
|
|
224
|
+
- **本技能的组织**:主文件给高频用法,完整参数表与高级示例在 `reference/data-stages.md`、`reference/workflow-cheatsheets.md`,需要时再展开;示例工程与生成的数据写到工作目录,不要改动技能目录本身。
|
|
225
|
+
- **执行环境**:命令在终端 / shell 中执行(Windows 用 PowerShell)。示例是 Linux/bash 写法,按平台改写 `apt`、`/tmp`、`export` 与反引号;Windows 路径加引号。
|
|
226
|
+
- **先探测工具链**:`gdalinfo --version`、`qgis_process --version`、`python3 -c "from osgeo import gdal; print(gdal.VersionInfo())"`、`curl -u admin:geoserver "http://localhost:8080/geoserver/rest/about/version.json"`;缺哪个阶段就加载相邻技能(如 `gis/gdal`、`gis/qgis-process`)。
|
|
227
|
+
- **分阶段交付**:每阶段产物落盘到工作区(GeoPackage/COG/GeoJSON),下一阶段只读取产物;先用 `ogrinfo -so`、`gdalinfo -json` 看摘要,不要把大文件或大段输出贴进上下文。
|
|
228
|
+
- **验证**:转换后重新打开结果核对 CRS、范围、要素数;发布后用 `curl` 回读 REST 资源或 `GetCapabilities`;无显示器环境设置 `QT_QPA_PLATFORM=offscreen`;`qgis_process` 参数先用 `qgis_process help <id> --json` 确认。
|
|
229
|
+
- **安全**:`gdal_edit.py`、覆盖输出、GeoServer `?recurse=true` 删除均不可逆;先备份并确认路径,安装 GDAL/QGIS、启动服务或使用数据库凭据前先征得用户同意。
|
|
230
|
+
|
|
231
|
+
---
|
|
232
|
+
|
|
435
233
|
## 相关技能
|
|
436
234
|
|
|
437
235
|
- **gdal** — GDAL 命令行工具:[../gdal/SKILL.md](../gdal/SKILL.md)
|
|
@@ -442,6 +240,10 @@ exporter.exportToPdf("/data/output.pdf", QgsLayoutExporter.PdfExportSettings())
|
|
|
442
240
|
- **geopipe-agent** — AI 驱动的 GIS 流水线:[../geopipe-agent/SKILL.md](../geopipe-agent/SKILL.md)
|
|
443
241
|
- **openlayers** — 前端 2D 地图可视化:[../openlayers/SKILL.md](../openlayers/SKILL.md)
|
|
444
242
|
- **cesiumjs** — 前端 3D 地球可视化:[../cesiumjs/SKILL.md](../cesiumjs/SKILL.md)
|
|
243
|
+
- **duckdb-spatial** — 用 SQL 直接分析 Shapefile/GeoParquet:[../duckdb-spatial/SKILL.md](../duckdb-spatial/SKILL.md)
|
|
244
|
+
- **geolibre** — 浏览器/桌面里做 GIS,无需服务端:[../geolibre/SKILL.md](../geolibre/SKILL.md)
|
|
245
|
+
- **whitebox-tools** — 地形/水文/LiDAR 批量分析:[../whitebox-tools/SKILL.md](../whitebox-tools/SKILL.md)
|
|
246
|
+
- **pdal** — 点云 LAS/LAZ 处理与 DEM 生成:[../pdal/SKILL.md](../pdal/SKILL.md)
|
|
445
247
|
|
|
446
248
|
## 参考资源
|
|
447
249
|
|