360 Secure SkillHub
360 安全技能中心

geoskill-spatial-data-validation

对本地矢量数据执行几何有效性、拓扑、属性完整性与 CRS 一致性四项检查,按权重合成 0-1 评分并映射 A-F 等级,输出 JSON 报告与无效几何 GeoJSON;支持合成缺陷数据离线复现,适合入库质检与验收自检。

ruiduobao
ruiduobao
热度 7.64
最近更新 2026-08-04 21:52:42
分类:数据依赖:代码执行 / 读写文件应用场景:数据处理 / 报告撰写

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add geoskill-spatial-data-validation
Metadata
name
geoskill-spatial-data-validation
description
检查矢量几何有效性、拓扑错误、属性完整性与 CRS 一致性,输出分级质量报告。Validate geometry validity, topology, attribute completeness and CRS consistency for vector data and emit a graded quality report.

空间数据质量验证 | Spatial Data Validation

Performs four-dimensional quality validation on vector data: geometry validity (shapely checks each feature for self-intersection, ring self-intersection, empty geometries, and null geometries, with reasons given), topology checks (duplicate geometry counts, pairwise polygon overlap detection), attribute completeness (null-value ratio per required field), and CRS consistency (actual EPSG compared against the expected value).

The four dimensions are combined by weights (geometry 0.40 / topology 0.20 / attributes 0.25 / CRS 0.15) into a 0–1 composite score, mapped to A–F grades, and invalid geometry features are exported as GeoJSON for manual review. Suitable for pre-load quality control, deliverable acceptance, and self-checks before data submission.

--synthetic mode generates features with intentionally planted defects (bowtie self-intersecting polygons, null geometries, missing attributes), reproducing all defect-detection paths offline.

Dependencies / 依赖

pip install numpy rasterio geopandas shapely fiona pyproj

Usage / 使用方法

Basic Usage

python geoskill-spatial-data-validation.py --bbox 116.0 39.0 117.0 40.0 --synthetic --output-dir ./out

Example 1 (Synthetic Data, Offline)

python geoskill-spatial-data-validation.py --bbox 116.0 39.0 117.0 40.0 --synthetic --output-dir ./out

示例 2:验证 Shapefile

python geoskill-spatial-data-validation.py --input parcels.shp --crs EPSG:4326 --output-dir ./report

Example 3: Custom Required Attribute Fields

python geoskill-spatial-data-validation.py --input buildings.gpkg --fields id,name,height,type --output-dir ./r2

示例 4:验证 GeoPackage 并检查投影一致性

python geoskill-spatial-data-validation.py --input roads.gpkg --crs EPSG:3857 --output-dir ./r3

Example 5: Silent Quality Check

python geoskill-spatial-data-validation.py --input data.geojson --quiet --output-dir ./r4

Output / 输出

File Format Description
validation_report.json JSON Four-dimension check results, composite score and grade
invalid_geometries.geojson GeoJSON Invalid geometry features (for review)
output-manifest.json JSON Run manifest

Data Source / 数据源 / Source

  • --input: local vector file (any OGR format)
  • --synthetic: locally generates defective test features

Privacy / 隐私声明 / Privacy

  • Runs offline by default; --synthetic mode requires no network at all.
  • All processing is done locally; no user data is uploaded.

License / License

MIT



name: geoskill-spatial-data-validation description: '检查矢量几何有效性、拓扑错误、属性完整性与 CRS 一致性,输出分级质量报告。Validate geometry validity, topology, attribute completeness and CRS consistency for vector data and emit a graded quality report.'

空间数据质量验证 | Spatial Data Validation

对矢量数据执行四个维度的质量验证:几何有效性(shapely 逐要素判定 self-intersection、ring 自交、空几何、null 几何并给出原因)、拓扑检查 (重复几何计数、多边形两两重叠检测)、属性完整性(逐必填字段统计 空值比例)、CRS 一致性(实际 EPSG 与期望值比对)。

四个维度按权重(几何 0.40 / 拓扑 0.20 / 属性 0.25 / CRS 0.15)合成 0-1 综合评分,映射为 A-F 等级,并把无效几何要素导出为 GeoJSON 供人工 复核。适合数据入库质检、成果验收、数据汇交前自检。

--synthetic 模式生成含刻意缺陷的要素(bowtie 自相交多边形、null 几何、 缺失属性),可离线复现全部缺陷检出路径。

依赖

pip install numpy rasterio geopandas shapely fiona pyproj

使用方法

基本用法

python geoskill-spatial-data-validation.py --bbox 116.0 39.0 117.0 40.0 --synthetic --output-dir ./out

示例 1(合成数据,离线)

python geoskill-spatial-data-validation.py --bbox 116.0 39.0 117.0 40.0 --synthetic --output-dir ./out

示例 2:验证 Shapefile

python geoskill-spatial-data-validation.py --input parcels.shp --crs EPSG:4326 --output-dir ./report

示例 3:自定义必填属性字段

python geoskill-spatial-data-validation.py --input buildings.gpkg --fields id,name,height,type --output-dir ./r2

示例 4:验证 GeoPackage 并检查投影一致性

python geoskill-spatial-data-validation.py --input roads.gpkg --crs EPSG:3857 --output-dir ./r3

示例 5:静默质检

python geoskill-spatial-data-validation.py --input data.geojson --quiet --output-dir ./r4

输出

文件 格式 说明
validation_report.json JSON 四维检查结果、综合评分与等级
invalid_geometries.geojson GeoJSON 无效几何要素(供复核)
output-manifest.json JSON 运行清单

数据源 / Source

  • --input:本地矢量文件(任意 OGR 格式)
  • --synthetic:本地生成含缺陷的测试要素

隐私声明 / Privacy

  • 默认离线运行,--synthetic 模式完全无网络。
  • 所有处理在本地完成,不上传用户数据。

License

MIT