AI Canopy-to-Impervious Ratio: Intelligent Urban Planning

Executive Summary #
Client:
Baum Schwyz (University Project)
The Main Win: An interactive map that shows where there is a lot of concrete and little shade. A single AI model detects tree canopy and sealed surfaces from aerial imagery alone. Whole regions are computed in advance: the map appears instantly instead of after a wait.
Tech Stack: PyTorch (DINOv2 + UPerNet), weak supervision from LiDAR and swisstopo data, PMTiles, MapLibre GL, React, FastAPI, Docker.
The Challenge #
Context: The
Baum Schwyz collective aims to mitigate urban heat islands and biodiversity loss by increasing tree cover in the Canton of Schwyz.
The Pain Point: Effective intervention requires knowing where a new tree brings the most benefit. Until now, decisions relied on “gut feeling” or manual surveys, both subjective and unscalable. High-resolution data on sealed surfaces (concrete, asphalt) simply did not exist for these regions.
Business Impact: Without precise data, trees end up where it is already green, while critical hotspots (high sealing, little shade) are missed.
The Solution #
Key Feature: The Canopy-to-Impervious Ratio (CIR). This metric relates shade to concrete per grid cell and produces a heatmap for decision-makers.
Version 1: The Working Prototype #
The first version combined two sources. Canopy came straight from LiDAR point clouds (vegetation above 3 m), sealed surfaces from a U-Net trained on hand-labelled aerial image crops. Users drew an area on the map, and a worker downloaded LiDAR and imagery and ran the analysis.
Decision: I started with YOLO (object detection) but pivoted quickly. A road is not an object with a bounding box like a car; it is a continuous, irregular surface. Semantic segmentation classifies every pixel and provides the precision needed for area calculations.

Why Version 1 Does Not Scale #
- Waiting time: Every analysis downloaded LiDAR afresh and computed on request. Users waited for every area.
- Data dependency: LiDAR is a cantonal patchwork with different survey years. No current point cloud, no analysis.
- Little training data: The hand labels covered few landscape types. The model mostly knew the Swiss Plateau.
Version 2: Aerial Imagery Only, Computed in Advance #
Decision: LiDAR stays in training but disappears from prediction. I generate the training labels automatically from LiDAR (canopy) and official vector data (buildings, roads, land cover). This yields labels for five cantons across four landscape regions without labelling a single pixel by hand. The model itself then sees only the aerial image.
Model: A pretrained vision model (DINOv2) stays frozen. On top sits a small decoder that predicts both classes in one pass. It is cheap to train and robust to new regions.
Delivery: Instead of computing per request, a batch process computes an entire region on a rented cloud GPU and produces static map files. The map loads them directly, with no database in between.
The Results #
- Sealed surfaces: ~83% IoU (Intersection-over-Union) with the production model, ~86% with an ensemble of two models. This meets the 85% target.
- Tree canopy: ~77% IoU (ensemble ~79%), just short of the 80% target.
- Stricter validation: Measured on test scenes in cantons the training never saw (Vaud, Neuchâtel, Ticino). Version 1’s ~85% came from the same region as its training data and is not directly comparable.
- Waiting time: From one analysis per request to zero. The Talkessel Schwyz (roughly 18 x 16 km) is computed in advance.
- Running costs: Building an entire region takes about two hours on a rented GPU and costs under 1 USD.
- Output: User-drawn areas can still be downloaded as a PNG heatmap or GIS shapefile.
Technical Architecture #
- Labels (offline): LiDAR (vegetation above 3 m) yields canopy. Buildings and roads from the official cadastral survey, swissTLM3D and OpenStreetMap yield sealed surfaces. Uncertain areas are ignored rather than learned as false negatives.
- Training: Frozen DINOv2 (ViT-B/14) with a UPerNet decoder and two outputs (canopy, impervious). Augmentation for other resolutions, colours and winter imagery.
- Region build: SWISSIMAGE 10 cm is split into overlapping 518 x 518 pixel crops, predicted and blended. The region runs in 2 x 2 km chunks, with GPU inference and CPU post-processing in parallel.
- Post-processing: Water mask, vectorisation, CIR raster with cell sizes from 20 to 160 m depending on zoom level.
- Delivery: Static PMTiles via nginx, plus a small region API for statistics and downloads.
Key Technical Challenges #
The Label Problem: A bigger model and unfreezing the backbone brought nothing; scores stayed flat or dropped. The bottleneck was not the model but the labels: green areas and tree crowns were partly marked as sealed.
The Fix: Better labels instead of a bigger model. Greenness and canopy now serve as hard negatives for sealed surfaces. Impervious precision rose from 78% to 90%, more than any model change had achieved.
The Lake Problem: The model marked 14 ha of Lake Lucerne and its rivers as sealed. Calm, dark water looks like fresh asphalt from the air, and the CIR cells over the lake turned red.
The Fix: Official water data. Lakes and rivers from swissTLM3D set sealing to zero. A 2 m shore band is excluded so quay walls and harbours stay visible. Result: 0 m² of sealed surface on water.
The Small Tree Problem: In Vaud, the model found only 64% of tree canopy. The obvious suspects (shadows, winter imagery, misalignment) were ruled out. Breaking recall down by object size showed it barely found crowns under 20 m²: garden trees and hedges.
The Fix: Weighting in training. Small crowns count three times in training. Recall in Vaud rose from 70% to 82%. Further label tricks brought no more progress after that. The next lever is a stronger backbone pretrained on aerial imagery.
Implementation Details #
I do not solve water inside the model but after prediction, using official data. That is cheaper and more reliable than retraining, and it can be applied to regions that were already built.
def apply_water(prob_u8: np.ndarray, water: BaseGeometry | None, transform) -> np.ndarray:
"""Zero the impervious band of ``prob_u8`` (2, H, W) on water. Returns the same array."""
wm = water_mask(water, transform, prob_u8.shape[1:])
if wm.any():
prob_u8[IMPERVIOUS_BAND][wm] = 0
return prob_u8
Logic: The swissTLM3D water polygons are first shrunk inwards by 2 m and rasterised per image block. Only the impervious channel is cleared; canopy along the shore is kept.
Infrastructure & Deployment #
- Static maps: Results are stored as PMTiles on nginx and loaded via HTTP range requests. No more database query per map view.
- Releases: Each region is uploaded into its own release folder and activated atomically by swapping a symlink. A rollback is one command.
- GPU on demand: Region builds run on rented cloud GPUs that terminate themselves on any failure. No idle GPU costs.
- CI/CD: GitLab CI runs tests, builds Docker images and deploys to a Linux VPS, with health checks and automatic rollback.
- Reproducibility: Data and labels are versioned with DVC, training runs logged with Weights & Biases.

Facing a similar question in your business? A first conversation costs nothing: around 30 minutes.
Free intro call