Skip to content
Back to skills

Straighten Edges

ASecurity

Remove staircase edges from raster-derived parcels with a junction graph and deviation test, preserving shared boundaries.

  • 8 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added September 19, 2026
developmentgonode

Security analysis

A100/100

Scanned September 19, 2026

npx -y skills add Adilmunawar/ZD-claude-plugin --skill straighten-edges --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Straighten Edges?

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

Security grade badge for Straighten Edges
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/adilmunawar-straighten-edges/badge)](https://www.skillsdirectory.com/skills/adilmunawar-straighten-edges)

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: straighten-edges
description: Remove staircase edges from raster-derived parcels with a junction graph and deviation test, preserving shared boundaries.
---

# Junction-graph straightening (topology preserving)

Simplifying polygons one at a time breaks shared edges. Work on the edge graph instead.

1. **Build the graph.** `edges = unary_union(gdf.boundary)`; `shapely.get_parts(edges)` yields each shared segment once. Load into a NetworkX undirected graph: nodes = segment endpoints (rounded to grid, e.g. 0.01 m in UTM), edge attribute = the LineString.
2. **Find junctions.** Nodes with degree > 2 (three or more parcels meet) and degree 1 (dangles). Paths between consecutive junctions are the units to straighten.
3. **Deviation test.** For each junction-to-junction path, compute the maximum perpendicular distance of any vertex from the chord joining the path's endpoints. If `max_deviation <= DEVIATION_THRESHOLD` (2.5 m works at 0.3 m imagery; use 1–2 px at Sentinel scale) replace the path with the chord; otherwise keep it, or apply `simplify(tol, preserve_topology=True)` only to that path.
4. **Rebuild faces.** `polygonize` the straightened edges; reassign attributes from the original parcels by largest intersection area.
5. **Verify.** Face count ≈ parcel count (differences are slivers to merge), overlaps 0, total area drift < 1 %. Report all three.

Optional orthogonalisation for field layers: snap path headings within ±10° of the local dominant orientation (from a histogram of edge azimuths in UTM) to that orientation before rebuilding.

Raster-first alternative when the mask still exists: `cv2.findContours` + `approxPolyDP(epsilon≈1.5 px)` per component label, then steps 1–5.

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…