Skip to content
Back to skills

Topology Repair

ASecurity

Fix invalid geometries, overlaps, gaps, slivers and mixed types in parcel layers while keeping shared edges. Apply after polygonisation, simplification or merge.

  • 8 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added September 19, 2026
ai-agentsgosql

Security analysis

A100/100

Scanned September 19, 2026

npx -y skills add Adilmunawar/ZD-claude-plugin --skill topology-repair --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Topology Repair?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Topology Repair
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/adilmunawar-topology-repair/badge)](https://www.skillsdirectory.com/skills/adilmunawar-topology-repair)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: topology-repair
description: Fix invalid geometries, overlaps, gaps, slivers and mixed types in parcel layers while keeping shared edges. Apply after polygonisation, simplification or merge.
---

# Topology repair

Order matters:
0. **Raster-side first** when a mask is available: fill thin gaps (distance transform, `MAX_GAP_FILL_PIXELS≈4`), close tiny corner holes (`≈7 px`), and cap component size (`MAX_COMPONENT_PIXELS`) so one giant blob cannot swallow a tile. Cheaper and cleaner than fixing the same defects in vector space.
1. `make_valid()` (shapely 2 / `ST_MakeValid`). Then drop empties and collections → keep only Polygon/MultiPolygon parts (`geom.geoms` filter), cast all to MultiPolygon. This fixes "mixed geometry type" export errors.
2. **Overlaps**: find with `gdf.sjoin(gdf, predicate='overlaps')`; for each pair assign the overlap to the larger parcel (`difference`) or split along the medial line if areas are similar. Re-check until 0.
3. **Gaps** between parcels that should touch: buffer-unbuffer (`buffer(tol).buffer(-tol)`) per polygon breaks sharing — instead, snap vertices with `shapely.snap(geom, neighbours, tol)` or build a planar graph: `unary_union` of all boundaries → `polygonize` → reassign attributes by largest-overlap join. This is the reliable way to get a clean shared-edge layer.
4. **Slivers**: area < min mapping unit or thinness (`4π·area/perimeter²`) < 0.05 → merge into the neighbour with the longest shared edge.
5. **Snap to grid** (`set_precision(geom, 0.5)` in metres) to stop floating-point re-overlaps.
6. Validate: invalid = 0, overlaps = 0, total area change < 0.5 % vs input. Report all three.

SQL equivalents: `ST_MakeValid`, `ST_CollectionExtract(geom, 3)`, `ST_Multi`, `ST_SnapToGrid`, `ST_Polygonize(ST_Union(ST_Boundary(geom)))`.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…