Hey community! ![]()
I’m a civil engineer and construction cost coordinator from Brazil.
I built this app to solve a real problem from my daily work —
and I want to share it here.
The Problem
Early-stage access roads and haul roads are often sketched quickly
in Google Earth. Turning those alignments into earthworks estimates
usually means:
- Manual coordinate extraction from KML
- External elevation queries (one by one)
- Repetitive spreadsheet formulas for cut/fill volumes
- No mass balance diagram
This process takes hours. And it’s error-prone.
The App
KML Earthworks automates the entire pipeline:
- Upload
.kmlfiles (exported from Google Earth) - App parses coordinates, builds chainage every 20m (Haversine)
- Queries terrain elevation via Open-Meteo API (OpenTopoData fallback)
- Fits a constrained grade line (SciPy optimization, max slope +
max height limits) - Computes cut/fill using prismatoid formula
(5–15% more accurate than average-end-area) - Applies shrink/swell factor, calculates borrow/waste per segment
- Generates interactive Plotly charts: plan view, terrain profile,
cut/fill bars, mass diagram, 3D view - Exports detailed Excel report
Zero GIS software required. Runs entirely in the browser.
Live app: https://kml-earthworks.streamlit.app
GitHub: GitHub - CAIOZANETTI/kml-earthworks: Automate terrain cut/fill estimation from KML access alignments, with interactive Plotly visualization and a Streamlit app. Includes optional elevation enrichment · GitHub
Tech Stack
- UI: Streamlit
- Charts: Plotly
- Data: pandas + NumPy + SciPy
- Elevation: Open-Meteo API + OpenTopoData fallback
- KML parsing: Python stdlib (no GDAL needed)
- Exports: openpyxl
- Type safety: TypedDict for all data structures
- Tests: 58 pytest tests covering all core modules (100% passing)
What I learned building this
The hardest part wasn’t the code — it was encoding engineering
judgment into logic.
For example: when should the grade line “cut” vs “fill”?
That depends on soil type, haul distance, shrink/swell factor,
and cost tradeoffs. A spreadsheet formula can’t hold that reasoning.
Python can.
This is my thesis: domain experts should build their own tools.
Streamlit made it possible for an engineer (not a software developer)
to go from problem to deployed app.
Happy to answer questions about the engineering logic, the
architecture decisions, or how I used AI assistance (Claude)
to accelerate development while keeping full technical
responsibility for every formula.
— Caio Zanetti | Civil Engineer & Builder
