HackArena 3.0 – Problem 1
Automatic and intelligent placement of river names inside complex river geometries.
Live Demo: https://gemini.google.com/share/af3786c81e62
This project implements a robust geometric algorithm to place river labels inside irregular river polygons while ensuring:
- Proper boundary padding
- High readability
- Flow-aligned orientation
- Visual consistency
Unlike centroid-based methods, this system analyzes river geometry and identifies the most suitable placement zone.
- Robust WKT file parsing
- Automatic MultiPolygon handling
- Safe-zone buffering (boundary protection)
- Oriented skeleton extraction
- Clearance-based optimization
- Flow-aligned text rotation
- Fallback placement mechanism
- High-quality visualization
The system follows a multi-stage geometric pipeline:
- Parse river geometry from WKT
- Extract the main river polygon
- Apply negative buffer to create safe zone
- Compute oriented centerline using scan lines
- Sample candidate positions
- Score candidates based on:
- Boundary clearance
- Local straightness
- Centrality
- Select best placement
- Rotate label along river flow
- Render final output
smart-river-labeling/ │ ├── final.py ├── Problem 1 - river.wkt ├── requirements.txt └── README.md
##⚙️ Installation
- Python 3.9+
- pip package manager
pip install -r requirements.txt
OR MANUALLY
pip install shapely matplotlib numpy