@dsh-gis/dsh-opengis-skill 0.1.2 → 0.2.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 +71 -0
- package/README.md +79 -43
- package/THIRD_PARTY_NOTICES.md +9 -0
- package/adaptations/brutile.md +8 -0
- package/adaptations/cesiumjs.md +8 -0
- package/adaptations/common.md +16 -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 +8 -0
- package/adaptations/opengis-daf.md +8 -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 +289 -0
- package/assets/cesiumjs/SKILL.md +78 -29
- package/assets/deck-gl/SKILL.md +20 -20
- package/assets/duckdb-spatial/SKILL.md +370 -0
- package/assets/gdal/SKILL.md +50 -55
- package/assets/gdal-api/SKILL.md +12 -29
- package/assets/geolibre/SKILL.md +364 -0
- package/assets/geometry-api-java/SKILL.md +11 -19
- package/assets/geometry-api-net/SKILL.md +66 -29
- package/assets/geonode/SKILL.md +347 -0
- package/assets/geopandas/SKILL.md +22 -28
- package/assets/geopipe-agent/SKILL.md +25 -30
- package/assets/geoserver/SKILL.md +21 -24
- package/assets/geoserver-cloud/SKILL.md +23 -34
- package/assets/geoserver-rest-api/SKILL.md +18 -23
- package/assets/geotools/SKILL.md +13 -21
- package/assets/grass-gis/SKILL.md +19 -20
- package/assets/jts/SKILL.md +12 -17
- package/assets/kepler-gl/SKILL.md +313 -0
- package/assets/leaflet/SKILL.md +42 -17
- package/assets/mapbox-gl-js/SKILL.md +19 -18
- package/assets/mapserver/SKILL.md +18 -18
- package/assets/mapsui/SKILL.md +87 -58
- package/assets/nettopologysuite/SKILL.md +96 -27
- package/assets/opengis-all/SKILL.md +80 -292
- package/assets/opengis-all/reference/data-stages.md +262 -4
- package/assets/opengis-daf/SKILL.md +12 -14
- package/assets/opengis-utils-for-java/SKILL.md +52 -47
- package/assets/opengis-utils-for-java/reference/common-tasks.md +12 -12
- package/assets/opengis-utils-for-net/SKILL.md +106 -40
- package/assets/opengis-utils-for-net/reference/code-patterns.md +11 -11
- package/assets/opengis-utils-for-net/reference/util-classes.md +25 -26
- package/assets/openlayers/SKILL.md +71 -14
- package/assets/pdal/SKILL.md +21 -15
- package/assets/postgis/SKILL.md +66 -18
- package/assets/proj/SKILL.md +29 -42
- package/assets/projnet4geoapi/SKILL.md +299 -0
- package/assets/pyqgis/SKILL.md +28 -54
- package/assets/qgis-process/SKILL.md +67 -39
- package/assets/qgis-server/SKILL.md +21 -32
- package/assets/shapely/SKILL.md +133 -84
- package/assets/sharpmap/SKILL.md +96 -61
- package/assets/spatialite/SKILL.md +365 -0
- package/assets/whitebox-tools/SKILL.md +269 -0
- package/lib/adaptations.d.ts +47 -0
- package/lib/adaptations.js +268 -0
- package/lib/index.d.ts +1 -1
- package/lib/index.js +14 -2
- package/lib/skill-file.js +31 -7
- package/locale/en.json +1 -1
- package/locale/zh.json +1 -1
- package/package.json +12 -2
- package/upstream.json +56 -40
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: opengis-all
|
|
3
|
-
description: "Use when navigating end-to-end GIS workflows —
|
|
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
4
|
|
|
5
5
|
tags:
|
|
6
6
|
- gis
|
|
@@ -91,7 +91,7 @@ export QT_QPA_PLATFORM=offscreen
|
|
|
91
91
|
|
|
92
92
|
```bash
|
|
93
93
|
# Docker 方式(推荐)
|
|
94
|
-
docker run -d -p 8080:8080 docker.osgeo.org/geoserver:3.0.
|
|
94
|
+
docker run -d -p 8080:8080 docker.osgeo.org/geoserver:3.0.2
|
|
95
95
|
|
|
96
96
|
# 验证
|
|
97
97
|
curl -u admin:geoserver "http://localhost:8080/geoserver/rest/about/version.json"
|
|
@@ -101,7 +101,7 @@ curl -u admin:geoserver "http://localhost:8080/geoserver/rest/about/version.json
|
|
|
101
101
|
|
|
102
102
|
---
|
|
103
103
|
|
|
104
|
-
>
|
|
104
|
+
> 阶段一(数据获取与信息查询)、阶段二(数据处理与转换)、阶段三(空间分析)的完整操作手册见 [reference/data-stages.md](reference/data-stages.md)
|
|
105
105
|
|
|
106
106
|
## 核心 API 与命令速查
|
|
107
107
|
|
|
@@ -119,278 +119,82 @@ curl -u admin:geoserver "http://localhost:8080/geoserver/rest/about/version.json
|
|
|
119
119
|
|
|
120
120
|
---
|
|
121
121
|
|
|
122
|
-
##
|
|
122
|
+
## 阶段三:空间分析(速查)
|
|
123
123
|
|
|
124
|
-
|
|
124
|
+
| 任务 | 命令入口 |
|
|
125
|
+
|------|----------|
|
|
126
|
+
| 缓冲区 | `qgis_process run native:buffer -- INPUT=... DISTANCE=... OUTPUT=...` |
|
|
127
|
+
| 交集/联合/差集 | `native:intersection / native:union / native:difference` |
|
|
128
|
+
| 融合 | `native:dissolve -- FIELD=...` |
|
|
129
|
+
| 空间连接 | `native:joinattributesbylocation -- PREDICATE=0` |
|
|
130
|
+
| 按属性/位置提取 | `native:extractbyattribute / native:extractbylocation` |
|
|
131
|
+
| 栅格波段运算 | `gdal_calc.py -A nir.tif -B red.tif --calc="(A-B)/(A+B)"` |
|
|
132
|
+
| DEM 分析 | `gdal_contour -i 10 / qgis_process run gdal:slope|aspect|hillshade` |
|
|
133
|
+
| 插值成 DEM | `gdal_grid -a invdist:power=2:zfield=Z` |
|
|
134
|
+
| 栅格矢量互转 | `gdal_polygonize.py / qgis_process run gdal:rasterize` |
|
|
135
|
+
| 地图渲染导出 | `PyQGIS QgsMapRendererSequentialJob / QgsLayoutExporter` |
|
|
125
136
|
|
|
126
|
-
|
|
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
|
-
```
|
|
142
|
-
|
|
143
|
-
```python
|
|
144
|
-
# PyQGIS (几何操作)
|
|
145
|
-
buffered = geom.buffer(100, 16)
|
|
146
|
-
```
|
|
147
|
-
|
|
148
|
-
```python
|
|
149
|
-
# GDAL Python API (OGR 几何)
|
|
150
|
-
from osgeo import ogr
|
|
151
|
-
pt = ogr.Geometry(ogr.wkbPoint)
|
|
152
|
-
pt.SetPoint_2D(0, 116.4, 39.9)
|
|
153
|
-
buffer = pt.Buffer(1.0)
|
|
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
|
-
```
|
|
269
|
-
|
|
270
|
-
### 3.7 散点插值(创建 DEM)
|
|
271
|
-
|
|
272
|
-
```bash
|
|
273
|
-
# 反距离加权(IDW)插值
|
|
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
|
-
```
|
|
137
|
+
> 完整的 3.1-3.10 逐项示例(qgis_process、PyQGIS、GDAL Python API 三种写法)见 [reference/data-stages.md](reference/data-stages.md)。
|
|
281
138
|
|
|
282
|
-
|
|
139
|
+
> 阶段四(发布 GIS 地图服务)的完整 GeoServer REST 操作见 [reference/data-stages.md](reference/data-stages.md)
|
|
140
|
+
> 端到端工作流示例、内置算法速查、GDAL 命令速查、数据格式与环境变量见 [reference/workflow-cheatsheets.md](reference/workflow-cheatsheets.md)
|
|
283
141
|
|
|
284
|
-
|
|
285
|
-
# 栅格转矢量(多边形化)
|
|
286
|
-
gdal_polygonize.py input.tif output.shp
|
|
142
|
+
## 典型工作流
|
|
287
143
|
|
|
288
|
-
|
|
289
|
-
qgis_process run gdal:polygonize -- INPUT=input.tif OUTPUT=output.shp
|
|
144
|
+
### 端到端:Shapefile → 缓冲分析 → GeoServer 发布 → Web 预览
|
|
290
145
|
|
|
291
|
-
|
|
292
|
-
qgis_process run gdal:rasterize -- \
|
|
293
|
-
INPUT=input.shp FIELD=value OUTPUT=output.tif
|
|
294
|
-
```
|
|
146
|
+
输入 `data/roads.shp`(EPSG:4326),输出 `http://localhost:8080/geoserver/wms` 上可用的图层 `demo:roads_buffer`。
|
|
295
147
|
|
|
296
|
-
|
|
148
|
+
1. **探索数据**:`ogrinfo -so -al data/roads.shp` 确认要素数与 CRS
|
|
149
|
+
2. **统一格式与坐标系**:`ogr2ogr -t_srs EPSG:3857 roads_3857.gpkg data/roads.shp`
|
|
150
|
+
3. **空间分析**:`qgis_process run native:buffer -- INPUT=roads_3857.gpkg DISTANCE=500 OUTPUT=roads_buffer.gpkg`
|
|
151
|
+
4. **验证结果**:`ogrinfo -so roads_buffer.gpkg roads_buffer` 核对方框与要素数
|
|
152
|
+
5. **发布服务**:GeoServer REST 建工作空间 → 上传 GeoPackage → 发布图层
|
|
153
|
+
6. **前端预览**:OpenLayers `TileWMS` 指向 `/geoserver/wms`,`LAYERS: 'demo:roads_buffer'`
|
|
297
154
|
|
|
298
155
|
```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")
|
|
156
|
+
# 1~4:本地分析与验证
|
|
157
|
+
ogrinfo -so -al data/roads.shp
|
|
158
|
+
ogr2ogr -t_srs EPSG:3857 roads_3857.gpkg data/roads.shp
|
|
159
|
+
QT_QPA_PLATFORM=offscreen qgis_process run native:buffer -- \
|
|
160
|
+
INPUT=roads_3857.gpkg DISTANCE=500 SEGMENTS=8 OUTPUT=roads_buffer.gpkg
|
|
161
|
+
ogrinfo -so roads_buffer.gpkg roads_buffer
|
|
162
|
+
|
|
163
|
+
# 5:发布(GeoServer 3.0.2,默认 admin/geoserver)
|
|
164
|
+
BASE=http://localhost:8080/geoserver/rest
|
|
165
|
+
curl -u admin:geoserver -X POST "$BASE/workspaces" \
|
|
166
|
+
-H 'Content-Type: application/json' \
|
|
167
|
+
-d '{"workspace":{"name":"demo"}}'
|
|
168
|
+
|
|
169
|
+
curl -u admin:geoserver -X PUT "$BASE/workspaces/demo/datastores/roads/file.gpkg?configure=all" \
|
|
170
|
+
-H 'Content-Type: application/geopackage+sqlite3' \
|
|
171
|
+
--data-binary @roads_buffer.gpkg
|
|
172
|
+
|
|
173
|
+
# 6:回读确认图层已发布
|
|
174
|
+
curl -u admin:geoserver "$BASE/layers/demo:roads_buffer.json"
|
|
361
175
|
```
|
|
362
176
|
|
|
363
|
-
```
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
177
|
+
```js
|
|
178
|
+
// 6:OpenLayers 前端预览
|
|
179
|
+
import Map from 'ol/Map.js';
|
|
180
|
+
import View from 'ol/View.js';
|
|
181
|
+
import TileLayer from 'ol/layer/Tile.js';
|
|
182
|
+
import TileWMS from 'ol/source/TileWMS.js';
|
|
183
|
+
|
|
184
|
+
new Map({
|
|
185
|
+
target: 'map',
|
|
186
|
+
layers: [new TileLayer({
|
|
187
|
+
source: new TileWMS({
|
|
188
|
+
url: 'http://localhost:8080/geoserver/wms',
|
|
189
|
+
params: { LAYERS: 'demo:roads_buffer', TILED: true }
|
|
190
|
+
})
|
|
191
|
+
})],
|
|
192
|
+
view: new View({ center: [12968000, 4863000], zoom: 12 })
|
|
193
|
+
});
|
|
379
194
|
```
|
|
380
195
|
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
> 阶段四(发布 GIS 地图服务)的完整 GeoServer REST 操作见 [reference/data-stages.md](reference/data-stages.md)
|
|
384
|
-
> 端到端工作流示例、内置算法速查、GDAL 命令速查、数据格式与环境变量见 [reference/workflow-cheatsheets.md](reference/workflow-cheatsheets.md)
|
|
196
|
+
**验收**:`curl -u admin:geoserver .../layers/demo:roads_buffer.json` 返回 200 且含 `"enabled": true`;前端地图能看到缓冲区图形。任一步失败都不要继续后续阶段——先修当前阶段的产物。
|
|
385
197
|
|
|
386
|
-
## 典型工作流
|
|
387
|
-
|
|
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
198
|
|
|
395
199
|
---
|
|
396
200
|
|
|
@@ -407,37 +211,6 @@ exporter.exportToPdf("/data/output.pdf", QgsLayoutExporter.PdfExportSettings())
|
|
|
407
211
|
|
|
408
212
|
---
|
|
409
213
|
|
|
410
|
-
## AI 使用建议
|
|
411
|
-
|
|
412
|
-
### 工具选择指南
|
|
413
|
-
|
|
414
|
-
| 场景 | 推荐工具 | 原因 |
|
|
415
|
-
|------|----------|------|
|
|
416
|
-
| 快速格式转换 | GDAL 命令行(ogr2ogr / gdal_translate) | 最简洁,适合脚本 |
|
|
417
|
-
| 复杂空间分析 | qgis_process 或 PyQGIS | 算法丰富,参数统一 |
|
|
418
|
-
| 编程集成 | GDAL API 或 PyQGIS | 灵活控制,适合程序嵌入 |
|
|
419
|
-
| 栅格波段运算 | gdal_calc.py | NumPy 语法,简单直观 |
|
|
420
|
-
| DEM 分析 | qgis_process (gdal:slope 等) | 一行命令完成 |
|
|
421
|
-
| 几何级别操作 | GDAL OGR API 或 PyQGIS QgsGeometry | 精确控制每个几何操作 |
|
|
422
|
-
| 服务发布 | GeoServer REST API | 唯一选择,HTTP 接口标准 |
|
|
423
|
-
| CI/CD 自动化 | qgis_process + GDAL CLI + curl | 命令行驱动,JSON 输出 |
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
### 关键注意事项
|
|
427
|
-
|
|
428
|
-
1. **始终使用绝对路径**:避免工作目录不确定导致文件找不到。
|
|
429
|
-
2. **始终使用 `--json` 选项**:JSON 输出结构化、易解析,是 AI 最友好的交互方式。
|
|
430
|
-
3. **先查 help 再构造参数**:`qgis_process help <id> --json` 确认参数定义。
|
|
431
|
-
4. **Headless 环境设置 `QT_QPA_PLATFORM=offscreen`**:在无显示器的服务器上必须设置。
|
|
432
|
-
5. **坐标系一致性**:空间运算前确保所有数据使用相同 CRS。
|
|
433
|
-
6. **文件上传格式**:GeoServer 上传 Shapefile 时需打包为 ZIP,且 ZIP 内须含 `.shp`、`.shx`、`.dbf`、`.prj`。
|
|
434
|
-
7. **GeoServer JSON 包装**:REST API 的 JSON 请求/响应均使用单层包装(如 `{"workspace":{...}}`)。
|
|
435
|
-
8. **recurse 参数**:删除 GeoServer 工作空间/数据存储时,添加 `?recurse=true` 级联删除。
|
|
436
|
-
9. **大数据优化**:启用 `GDAL_NUM_THREADS=ALL_CPUS`,增大 `GDAL_CACHEMAX`;PyQGIS 中使用 `QgsSpatialIndex`。
|
|
437
|
-
10. **始终备份**:GDAL 可就地修改文件(如 `gdal_edit.py`),操作前做好备份。
|
|
438
|
-
|
|
439
|
-
---
|
|
440
|
-
|
|
441
214
|
## 常见问题
|
|
442
215
|
|
|
443
216
|
| 问题 | 解决 |
|
|
@@ -452,6 +225,17 @@ exporter.exportToPdf("/data/output.pdf", QgsLayoutExporter.PdfExportSettings())
|
|
|
452
225
|
|
|
453
226
|
---
|
|
454
227
|
|
|
228
|
+
## AI 使用建议
|
|
229
|
+
|
|
230
|
+
- **本技能的组织**:主文件给高频用法,完整参数表与高级示例在 `reference/data-stages.md`、`reference/workflow-cheatsheets.md`,需要时再展开;示例工程与生成的数据写到工作目录,不要改动技能目录本身。
|
|
231
|
+
- **执行环境**:命令在终端 / shell 中执行(Windows 用 PowerShell)。示例是 Linux/bash 写法,按平台改写 `apt`、`/tmp`、`export` 与反引号;Windows 路径加引号。
|
|
232
|
+
- **先探测工具链**:`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`)。
|
|
233
|
+
- **分阶段交付**:每阶段产物落盘到工作区(GeoPackage/COG/GeoJSON),下一阶段只读取产物;先用 `ogrinfo -so`、`gdalinfo -json` 看摘要,不要把大文件或大段输出贴进上下文。
|
|
234
|
+
- **验证**:转换后重新打开结果核对 CRS、范围、要素数;发布后用 `curl` 回读 REST 资源或 `GetCapabilities`;无显示器环境设置 `QT_QPA_PLATFORM=offscreen`;`qgis_process` 参数先用 `qgis_process help <id> --json` 确认。
|
|
235
|
+
- **安全**:`gdal_edit.py`、覆盖输出、GeoServer `?recurse=true` 删除均不可逆;先备份并确认路径,安装 GDAL/QGIS、启动服务或使用数据库凭据前先征得用户同意。
|
|
236
|
+
|
|
237
|
+
---
|
|
238
|
+
|
|
455
239
|
## 相关技能
|
|
456
240
|
|
|
457
241
|
- **gdal** — GDAL 命令行工具:[../gdal/SKILL.md](../gdal/SKILL.md)
|
|
@@ -462,6 +246,10 @@ exporter.exportToPdf("/data/output.pdf", QgsLayoutExporter.PdfExportSettings())
|
|
|
462
246
|
- **geopipe-agent** — AI 驱动的 GIS 流水线:[../geopipe-agent/SKILL.md](../geopipe-agent/SKILL.md)
|
|
463
247
|
- **openlayers** — 前端 2D 地图可视化:[../openlayers/SKILL.md](../openlayers/SKILL.md)
|
|
464
248
|
- **cesiumjs** — 前端 3D 地球可视化:[../cesiumjs/SKILL.md](../cesiumjs/SKILL.md)
|
|
249
|
+
- **duckdb-spatial** — 用 SQL 直接分析 Shapefile/GeoParquet:[../duckdb-spatial/SKILL.md](../duckdb-spatial/SKILL.md)
|
|
250
|
+
- **geolibre** — 浏览器/桌面里做 GIS,无需服务端:[../geolibre/SKILL.md](../geolibre/SKILL.md)
|
|
251
|
+
- **whitebox-tools** — 地形/水文/LiDAR 批量分析:[../whitebox-tools/SKILL.md](../whitebox-tools/SKILL.md)
|
|
252
|
+
- **pdal** — 点云 LAS/LAZ 处理与 DEM 生成:[../pdal/SKILL.md](../pdal/SKILL.md)
|
|
465
253
|
|
|
466
254
|
## 参考资源
|
|
467
255
|
|