Memory

geoskill-vector-simplification

Try it

用 Douglas-Peucker / Visvalingam 算法简化矢量几何,统计顶点减少与面积保持。Simplify vector geometries with Douglas-Peucker / Visvalingam and report vertex reduction and area retention.

What it does

用 Douglas-Peucker / Visvalingam 算法简化矢量几何,统计顶点减少与面积保持。Simplify vector geometries with Douglas-Peucker / Visvalingam and report vertex reduction and area retention.

The skill document

矢量简化 | Vector Simplification

Reduces the number of vertices in vector geometries with two classic line simplification algorithms, for small-scale cartographic generalization, data volume reduction and lower tile rendering load:

  • Douglas-Peucker: iterative implementation that compares the perpendicular distance of points to the chord against a tolerance epsilon and removes points within the tolerance band; good shape preservation and the most widely used line/area simplification algorithm.
  • Visvalingam-Whyatt: iteratively removes the point with the smallest "effective area" (the triangle area of three adjacent points) and supports stopping by an area threshold; smoother for jagged lines.

LineString / Polygon (with holes) / Multi* / GeometryCollection geometries are simplified recursively; simplified rings are guaranteed to remain closed with no fewer than 3 points. Reports the vertex reduction ratio and the polygon area retention rate. --synthetic mode generates a high-density circle (64 vertices) and a jagged line as test features.

Dependencies / 依赖

pip install numpy rasterio geopandas shapely fiona pyproj

Usage / 使用方法

Basic Usage

python geoskill-vector-simplification.py --bbox 116.0 39.0 117.0 40.0 --synthetic --output-dir ./out

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

python geoskill-vector-simplification.py --bbox 116.0 39.0 117.0 40.0 --synthetic --method douglas-peucker --tolerance 0.001 --output-dir ./dp

示例 2:简化道路 Shapefile

python geoskill-vector-simplification.py --input roads.shp --method douglas-peucker --tolerance 0.0005 --output-dir ./roads_simp

示例 3:Visvalingam 面积阈值简化边界

python geoskill-vector-simplification.py --input boundary.gpkg --method visvalingam --tolerance 0.00001 --output-dir ./visv

示例 4:合成数据 Visvalingam

python geoskill-vector-simplification.py --bbox 116.0 39.0 117.0 40.0 --synthetic --method visvalingam --tolerance 0.0001 --output-dir ./visv2 --quiet

Example 5: Large-Tolerance Quick Overview

python geoskill-vector-simplification.py --input coast.geojson --method douglas-peucker --tolerance 0.01 --output-dir ./coarse

Output / 输出

FileFormatDescription
simplified.geojsonGeoJSONSimplified features
simplification_stats.jsonJSONVertex reduction ratio, area retention rate
output-manifest.jsonJSONRun manifest

Data Source / 数据源 / Source

  • --input: local vector file
  • --synthetic: locally generated high-density test features

Privacy / 隐私声明 / Privacy

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

License / License

MIT



name: geoskill-vector-simplification description: '用 Douglas-Peucker / Visvalingam 算法简化矢量几何,统计顶点减少与面积保持。Simplify vector geometries with Douglas-Peucker / Visvalingam and report vertex reduction and area retention.'

矢量简化 | Vector Simplification

用两种经典线简化算法减少矢量几何顶点数,用于小比例尺制图综合、降低 数据量与瓦片渲染负载:

  • Douglas-Peucker:迭代版实现,比较点到弦的垂直距离与容差 epsilon, 删除容差带内的点,保形性好,是最常用的线/面简化算法。
  • Visvalingam-Whyatt:迭代删除“有效面积”(相邻三点三角形面积)最小 的点,支持按面积阈值停止;对锯齿状线更平滑。

对 LineString / Polygon(含孔)/ Multi* / GeometryCollection 递归简化, 环简化后保证闭合且不少于 3 点。统计顶点减少比例与多边形面积保持率。 --synthetic 模式生成高密度圆(64 顶点)与锯齿线作为测试要素。

依赖

pip install numpy rasterio geopandas shapely fiona pyproj

使用方法

基本用法

python geoskill-vector-simplification.py --bbox 116.0 39.0 117.0 40.0 --synthetic --output-dir ./out

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

python geoskill-vector-simplification.py --bbox 116.0 39.0 117.0 40.0 --synthetic --method douglas-peucker --tolerance 0.001 --output-dir ./dp

示例 2:简化道路 Shapefile

python geoskill-vector-simplification.py --input roads.shp --method douglas-peucker --tolerance 0.0005 --output-dir ./roads_simp

示例 3:Visvalingam 面积阈值简化边界

python geoskill-vector-simplification.py --input boundary.gpkg --method visvalingam --tolerance 0.00001 --output-dir ./visv

示例 4:合成数据 Visvalingam

python geoskill-vector-simplification.py --bbox 116.0 39.0 117.0 40.0 --synthetic --method visvalingam --tolerance 0.0001 --output-dir ./visv2 --quiet

示例 5:大容差快速概览

python geoskill-vector-simplification.py --input coast.geojson --method douglas-peucker --tolerance 0.01 --output-dir ./coarse

输出

文件格式说明
simplified.geojsonGeoJSON简化后的要素
simplification_stats.jsonJSON顶点减少比例、面积保持率
output-manifest.jsonJSON运行清单

数据源 / Source

  • --input:本地矢量文件
  • --synthetic:本地生成高密度测试要素

隐私声明 / Privacy

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

License

MIT

Related skills

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

1 installs

对矢量数据做变更检测、版本快照与差异比较,支持 commit / diff / log 操作。Change detection, version snapshots and diff comparison for vector data with commit / diff / log operations.

基于 GDAL / OGR 批量转换栅格与矢量格式 (GeoTIFF / Shapefile / GeoPackage / GeoJSON) 并记录日志。Batch convert raster and vector formats (GeoTIFF / Shapefile / GeoPackage / GeoJSON) via GDAL / OGR with logging.

交通噪声衰减模型制图 dB(A) 等级:FHWA 简化声源级、点/线源几何发散、建筑屏障衰减与地面吸收。Maps traffic noise levels with distance attenuation, building shielding and terrain. 输出噪声级 GeoTIFF + 参数 JSON。

1 installs

在 GeoPackage 中建表、导入矢量要素、创建空间索引并执行空间查询。Create tables, import vector features, build spatial indexes and run spatial queries in a GeoPackage.