Theil-Sen estimator¶
The estimator (pypvroof.theilsen) fits roof planes on the elevations under a
polygon, robustly to misregistered polygons, chimneys and edges.
- Masking. Pixels whose centre lies in the polygon, eroded by
erosion(gutters, edges) when enough pixels remain. - Random subsets.
n_subsetssubsets ofsubset_sizepixels (3 = exact planes), drawn withinsubset_radiusso that they stay on one pan. Degenerate subsets are dropped. - Modes. The plane gradients are clustered in gradient space
(
bandwidth); each mode is an orientation. Parallel planes with the same orientation (sheds, repeated gables) are separated by their intercepts. - Assignment and refit. Each pixel goes to the closest plane
(
inlier_tol), and each plane is refitted by least squares on its pixels. - Decision.
- one plane:
ok, orflatbelowflat_tilt; - a secondary plane that is too steep (
max_tilt), too small (min_part_area), or a band along the polygon's edge (edge_band,edge_frac) while the main one dominates (dominant_share) is treated as a misregistration or an obstacle (offset_suspected=True); - otherwise
multimodal.
- one plane:
Parameters¶
Pass them to characterize_roofs (params=) as a dict or as a
TheilSenParams. Unknown keys raise an error.
Distances in metres, angles in degrees.
from pypvroof import TheilSenParams, characterize_roofs
out = characterize_roofs(polys, "fr-lidar", params={"flat_tilt": 3, "n_subsets": 4000})
| Parameter | Default | Role |
|---|---|---|
n_subsets |
2000 | number of random subsets |
subset_size |
3 | pixels per subset (3 = exact planes) |
subset_radius |
3.0 | max distance between the pixels of a subset |
min_subset_spread |
0.5 | min area (m²) covered by a subset |
seed |
42 | random seed |
min_pixels |
12 | min valid pixels under the (eroded) polygon |
min_area |
2.0 | min area (m²) of these pixels |
erosion |
0.5 | polygon erosion before estimation |
bandwidth |
0.05 | mode width, in gradient units (tan(tilt)) |
peak_min_ratio |
0.2 | min peak height relative to the highest peak |
max_modes |
4 | gradient modes (orientations) |
max_planes |
16 | planes, counting parallel ones |
search_max_tilt |
75.0 | steeper gradients are ignored |
inlier_tol |
0.15 | max elevation residual (m) to belong to a plane |
min_mode_share |
0.10 | min share of pixels for a plane to count... |
min_plane_area |
8.0 | ... unless it covers this area (m²), on large polygons |
max_tilt |
60.0 | steeper secondary planes are implausible (facades) |
flat_tilt |
5.0 | below: flat roof, azimuth undefined |
same_tilt |
5.0 | planes closer than this in tilt... |
same_azimuth |
15.0 | ... and in azimuth share an orientation |
min_part_area |
3.0 | min area (m²) of a secondary plane / split part |
dominant_share |
0.75 | share above which the main plane dominates |
edge_band |
1.0 | width of the band along the polygon's edge |
edge_frac |
0.8 | share of a secondary plane in the edge band to call it an edge effect |
Diagnostics¶
| Column | Meaning |
|---|---|
n_pixels |
valid pixels used |
n_modes |
orientations found |
primary_share |
share of pixels on the main plane |
inlier_frac |
share of pixels assigned to a plane |
rmse |
residual of the main plane (m) |
roughness |
dispersion around the plane (racks on flat roofs) |
offset_suspected |
a secondary plane was attributed to misregistration or an obstacle |
modes |
the planes found (tilt, azimuth, share) |