Files
gis-actions/suites/test-windows/workflow.yaml
T

117 lines
4.1 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
name: 云南省界叠加分析(Windows 测试)
description: |
验证 GIS Actions 4.0 **Windows 双平台**arcpy + Python3)执行链路的官方测试套件。
---
**内置测试数据**
套件包内置 4 个 GeoJSON 文件,开箱即用:
| 文件 | 内容 | 角色 |
|------|------|------|
| `yunnan.geojson` | 云南省界(面) | 叠加分析的目标区域 |
| `kunming.geojson` | 昆明市界(面) | 预期在省内 → 通过 |
| `dali.geojson` | 大理州界(面) | 预期在省内 → 通过 |
| `baise.geojson` | 广西百色市界(面) | 预期不在省内 → 不通过 |
**▎执行流程**
| 步骤 | 运行时 | 功能 |
|------|--------|------|
| 1. GeoJSON → SHP | arcpy | 内置 GeoJSON 转为 Shapefile |
| 2. 叠加分析 | arcpy | 空间选择判断城市是否在省界内 |
| 3. Excel 输出 | Python3openpyxl | 格式化报表含条件高亮 |
**▎预期输出**
输出 Excel 工作簿包含 **叠加分析结果** 工作表:
| 城市 | 城市代码 | 城市名称 | 人口 | 在省内 | 相交 | 状态 |
|------|----------|----------|------|--------|------|------|
| kunming | 530100 | 昆明市 | 8,500,000 | 是 | 是 | 通过 ✅ |
| dali | 532900 | 大理州 | 3,300,000 | 是 | 是 | 通过 ✅ |
| baise | 451000 | 百色市 | 3,600,000 | 否 | 是 | 不通过 ❌ |
**条件格式:** 通过行绿色背景,不通过行红色背景。
**▎环境要求**
- Step 1、2 依赖系统 **ArcGIS 10.x**arcpyPython 2.7 环境)
- Step 3 使用系统本机 **Python 3** 运行时(需安装 openpyxl
- 建议安装顺序:ArcGIS → Python 3 → `pip install openpyxl`
version: 1.0.2
author: Robert
platform: windows
slug: test-yunnan-overlay-windows
tags: [测试, 叠加分析, Windows, 云南省, 验证套件]
category: 测试验证
params:
output_path:
type: string
required: true
desc: |
输出 Excel 文件路径,例如 `C:\Users\test\output\result.xlsx`。
输出文件包含一张 **叠加分析结果** 工作表,表头加粗、蓝色底白色字;
通过行绿色高亮,不通过行红色高亮。
steps:
- id: geojson_to_shp
name: 内置数据 → 转为 Shapefile
description: |
从套件包内置 `data/` 目录读取 4 个 GeoJSON 文件(云南省界 + 昆明/大理/百色),
使用 **arcpy.JSONToFeatures_conversion** 工具将 JSON 转为要素类并输出为 Shapefile,
存入共享工作目录 `/tmp/output/shp/`。
⚠️ 本步骤运行在 **Python 2.7arcpy** 环境。
runtime: arcpy
script_id: arcpy_convert
params:
output_dir: /tmp/output/shp
- id: overlay
name: 叠加分析(空间选择)
description: |
读取省界 Shapefile,创建要素图层。
对每个城市 Shapefile 使用 **FeatureToPoint** 计算几何中心点,
再通过 **SelectLayerByLocation**(空间关系:WITHIN)判断中心点是否在省界内。
分析结果以 JSON 格式输出到 `/tmp/output/result/`。
**预期结果:**
- 昆明市 → 在省内 ✅
- 大理州 → 在省内 ✅
- 百色市 → 不在省内 ❌(验证"不过"分支)
⚠️ 本步骤运行在 **Python 2.7arcpy** 环境。
runtime: arcpy
script_id: arcpy_overlay
depends_on: [geojson_to_shp]
params:
province_shp: /tmp/output/shp/province.shp
cities_dir: /tmp/output/shp
output_dir: /tmp/output/result
- id: export_excel
name: 输出 Excel 报表
description: |
读取上一步产生的叠加分析结果 JSON,使用 **openpyxl** 生成格式化的 Excel 工作簿。
**格式细节:**
- 表头:加粗、白色字体、蓝色背景(#4472C4)
- 通过行:绿色背景(#E2EFDA)
- 不通过行:红色背景(#FCE4EC)
- 自动调整列宽
输出文件写入用户指定的 `output_path`。
⚠️ 本步骤使用 **Python 3** 运行时在 Windows 本机执行。
runtime: python3
script_id: excel
depends_on: [overlay]
params:
result_dir: /tmp/output/result
output_path: $params.output_path