Repository navigation
CAD vectorization audit
Local date: 2026-10-21, Europe/Berlin.
Completed component: src/pvextent/cad/ and CLI subcommand pvextent vectorize.
Demonstration artifacts: artifacts/cad-vectorization-v1/.
In Step 3 of the aerial segmentation program, we engineered a CAD-grade geospatial vectorization and rectilinear regularization pipeline. Raw neural network segmentation masks suffer from discrete pixel-staircase artifacts, eroded corners, and jagged boundaries that cannot be ingested directly into CAD, GIS, or solar planning systems.
To elevate spacement-pvextent to defense- and intelligence-grade fidelity ("Palantir-Niveau"), the new src/pvextent/cad engine transforms raster inference outputs into clean, survey-grade orthogonal vector polygons with complete photovoltaic capacity and geometric telemetry.
- Topology-Preserving Marching Squares: Extracts closed, non-self-intersecting boundary contours directly from binary or thresholded probability rasters without external C++ or OpenCV dependencies, guaranteeing 100% deterministic portability.
- Douglas-Peucker Simplification: Prunes collinear pixel-step vertices while strictly preserving structural corner vertices.
-
90° Manhattan Rectilinear Regularization:
- Detects the dominant roof azimuth
$\theta_{\text{dom}} \in [0, \pi/2)$ using length-weighted 4-fold circular trigonometry:$$\theta_{\text{dom}} = \frac{1}{4} \text{atan2}\left(\sum L_i \sin(4\theta_i), \sum L_i \cos(4\theta_i)\right)$$ - Rotates the polygon into the canonical frame, snaps near-orthogonal segments within angular tolerance (
$\pm 20^\circ$ ) to strict horizontal/vertical lines, and reconstructs clean$90^\circ$ intersecting vertices. - Rotates regularized vertices back to the original coordinate space, eliminating all raster staircasing while preserving true module dimensions.
- Detects the dominant roof azimuth
-
Physical Photovoltaic & Electrical Modeling:
- Surface area in
$m^2$ via the Gauss-Shoelace formula:$A_{m^2} = A_{\text{px}} \times (\text{GSD})^2$ . - Nominal DC peak power output:
$$P_{\text{dc}} (kW_p) = A_{m^2} \times \eta \times 1.0\text{ kW/m}^2$$ (Standard monocrystalline STC efficiency$\eta = 20.5% \implies 205\text{ W}_p/m^2$ ). - Standard 400 W module equivalent count:
$\text{Modules} = \text{round}(P_{\text{dc}} / 0.400\text{ kW})$ . - Array azimuth in compass degrees (
$0^\circ = \text{North}, 180^\circ = \text{South}$ ). - Minimum area oriented bounding box (OBB) length, width, and aspect ratio.
- Surface area in
-
Georeferencing & Standard GeoJSON Export:
Applies GDAL-style 6-parameter affine transforms to project image coordinates
$(x, y)$ into projected map coordinates (EPSG:25832 UTM zone 32N) and exports RFC 7946 GeoJSONFeatureCollectionfiles compatible with QGIS, ArcGIS, Mapbox, and Palantir Foundry.
The complete pipeline was evaluated on the unseen positive holdout crops using the newly trained DeepLabV3+ ResNet50 Focal+Lovász checkpoint (runs/deeplabv3plus-resnet50-focal-lovasz-v4-001/best.pt):
| Crop ID / Location | Detected Arrays | Total PV Area ( |
Peak Capacity ( |
Estimated 400W Modules | Dominant Azimuth |
|---|---|---|---|---|---|
Crop 1 (nrw-DENW07AL0000ytXZBL) |
16 arrays | 112.30 |
23.02 |
58 modules | 171.4° (South-South-East) |
Crop 2 (nrw-DENW53AL0000StB8BL) |
7 arrays | 85.19 |
17.46 |
44 modules | 180.0° (Direct South) |
Crop 3 (nrw-DENW53AL0000mo4NBL) |
14 arrays | 133.63 |
27.40 |
71 modules | 180.0° (Direct South) |
Visual inspection confirmed that jagged raster steps were converted into sharp, straight CAD lines aligned with roof geometry.
The pipeline is exposed directly via the pvextent CLI:
# Vectorize from raw image using the trained DeepLabV3+ checkpoint
pvextent vectorize <input_image.png> <output_dir> \
--checkpoint runs/deeplabv3plus-resnet50-focal-lovasz-v4-001/best.pt \
--threshold 0.25 \
--gsd 0.10 \
--json
# Vectorize from an existing binary mask
pvextent vectorize <mask.png> <output_dir> --gsd 0.10Outputs generated:
-
vectorized.geojson: Standard RFC 7946 GeoJSON FeatureCollection with coordinates and properties. -
cad_overlay.png: High-contrast transparent CAD overlay with emerald module boundaries and$kW_p$ /$m^2$ badges.
Developed and maintained by Valeford under the Spacement brand. Original project code: Apache-2.0. See the repository NOTICE for attribution.
Spacement PVExtent
- Home
- PVExtent Vidda vs. Tinden (v1.0 Releases)
- Getting started
- Dataset format
- Annotation guide
- PV4GER-SEG import
- Import audit
- Geographic splits
- Split audit
- Label review
- NRW candidates
- Bulk NRW training imagery
- Bulk mask curation
- Live training monitor
- Training quality exclusions
- Final bulk mask audit
- Experimental negative curation
- Negative curation audit
- Exploratory negative holdout
- Negative holdout audit
- Exploratory positive holdout
- Positive holdout audit
- Training smoke test
- Smoke audit
- Pretrained baseline training
- Baseline comparison
- Baseline comparison audit
- Six-epoch continuation audit
- V4 bulk training audit
- Domain-balanced training audit
- DeepLabV3+ ASPP architecture audit
- DeepLabV3+ Focal + Lovász loss audit
- DeepLabV3+ V5 Photometric Invariance audit
- CAD vectorization & rectilinear audit
- Test-Time Augmentation (TTA) audit
- Probability calibration & temperature scaling audit
- Seamless overlapping tiled inference & Hann blending audit
- Heterogeneous ensemble & quality triage audit
- Sealed 421 test benchmark audit
- 3D elevation & solar yield audit
- Multi-temporal 4D change detection audit
- Multispectral NIR & spectral signature audit
- Encoder weights and licenses
- Baseline audit
- Frozen validation errors
- Validation error audit
- Candidate predictions
- Research roadmap
Project