Bulk characterization¶
characterize_roofs measures the tilt and azimuth of the roof planes under a
set of polygons, from a surface model service, with the
Theil-Sen estimator, or estimates them from the polygons alone
(service=None). It adds the installed capacity on request.
from pypvroof import characterize_roofs
out = characterize_roofs(
"detections.parquet",
service="fr-lidar",
crs=None, # CRS of inputs that do not carry one (default EPSG:4326)
params=None, # dict or TheilSenParams
split=False, # split polygons covering several roof planes
workers=8, # polygons processed concurrently (threads)
id_column=None, # copied into parent_id (default: the input index)
meta_prefix="meta_",
progress=None, # optional callable(done, total)
capacity=None, # "constant", "linear", "clustered" or kWp/m²
tilt=30.0, # tilt of the heuristics (service=None)
)
Inputs¶
- a GeoDataFrame or GeoSeries;
- a DataFrame with a
geometrycolumn (shapely or WKB); - a GeoJSON dict (Feature, FeatureCollection), a list of features or of shapely geometries;
- a path: GeoJSON, GeoPackage, (Geo)Parquet...
Polygons can be in any CRS; they are reprojected to the service's CRS.
GeoJSON files with unclosed rings or self-intersecting polygons are repaired
(make_valid).
Output¶
A GeoDataFrame in the CRS of the input, one row per polygon (or per part with
split=True), with the input columns (suffixed _input when they clash),
parent_id, part, and:
| Column | Content |
|---|---|
tilt, azimuth |
degrees (NaN when not measured; azimuth NaN on flat roofs) |
status |
see below |
inspect |
True when a human should look at the polygon (multimodal) |
surface_proj, surface |
projected area (m²), area corrected for the tilt |
n_pixels, n_modes, primary_share, inlier_frac, rmse, roughness, offset_suspected, modes |
diagnostics |
meta_* |
metadata returned by the service, passed through as is |
installed_capacity |
kWp, with capacity (see methods) |
elongation |
long side / short side of the polygon's rectangle, with service=None |
Statuses¶
| Status | Meaning |
|---|---|
ok |
one roof plane, tilt and azimuth measured |
flat |
flat roof (tilt < flat_tilt), azimuth undefined. A high roughness hints at racks |
multimodal |
several roof planes under the polygon: no value, inspect=True (or split) |
too_few_points |
too few valid pixels (very small polygon) |
fit_failed |
no plane could be fitted |
no_coverage |
the service has no data here |
service_error |
the service failed (after retries); retrying later may work |
too_large |
polygon too large for a single request |
error |
unexpected exception (see meta_error) |
heuristic |
service=None: constant tilt, azimuth from the polygon's rectangle |
pypvroof never applies a fallback. Typical strategies, left to the caller:
out = characterize_roofs(polys, "fr-lidar")
# retry the polygons outside LiDAR HD with MNS Correl
missing = out.status == "no_coverage"
retry = characterize_roofs(polys[missing.values], "fr-correl")
# heuristics for what remains
heur = characterize_roofs(polys[missing.values], None, tilt=30)
Other checks: inspect multimodal rows, or compare the LiDAR acquisition date
(meta_date_fin_acquisition) with the installation date.
Splitting multi-plane polygons¶
With split=True, a multimodal polygon is split into one part per roof
plane. Each part is a row with the same parent_id and its own part
number, geometry, tilt and azimuth.
out = characterize_roofs(polys, "fr-lidar", split=True)
out.groupby("parent_id").size() # number of planes per input polygon
Installed capacity¶
The capacity is computed from surface (panel surface, corrected for the
tilt), so each roof plane gets its own value with split=True. Rows without
a tilt have no capacity. For surfaces computed elsewhere, use
pypvroof.installed_capacity(surface, method).
Without a surface model¶
Each polygon gets the constant tilt, the azimuth of its minimum rotated
rectangle (normal to the long side, on the side closest to south), the
elongation of that rectangle and status = "heuristic". The azimuth is
arbitrary on squarish polygons: filter on elongation if needed. No request
is made; split, params and workers are ignored.
Concurrency¶
The work is dominated by I/O for remote services: workers threads query the
service in parallel. Mind the usage limits of the public services (Poland's
pl takes about 7 s per polygon).