Skip to main content

PyPVRoof

Try it on Hugging Face PyPI DOI

PyPVRoof extracts the characteristics of rooftop PV systems from geocoded polygons.

  • Outputs: tilt, azimuth, installed capacity (plus surface and location).
  • Inputs: the polygons, and optionally a digital surface model (DSM). Open DSMs of several European countries are queried on the fly (see Covered countries); local GeoTIFFs work too. Without a DSM, heuristics give an estimate from the polygon alone.

pypvroof pipeline: PV polygons, a service fetches the surface model under each polygon, Theil-Sen fits the roof plane(s), output characteristics with a status; without a surface model, heuristics from the polygon

Try it online on Hugging Face Spaces: draw a polygon on a roof anywhere in the covered countries and get its characteristics on the fly, or upload a file of polygons. Locally: pip install -e ".[viz]" gradio && python app/app.py.

Methods

Tilt

  • With a DSM: the elevations under the polygon are fitted with a robust Theil-Sen estimator: planes through random triplets of neighbouring pixels, modes of their slopes (one per orientation, with as many parallel planes as needed), least-squares refit on the inliers. Polygons covering several roof planes with different orientations are flagged multimodal, or split into one part per plane (split=True): gable roofs, but also large roofs with many pans (repeated gables, sheds).
  • Without a DSM: a constant (30° by default, constant-tilt).

Azimuth

  • With a DSM: from the same Theil-Sen fit. Undefined on flat roofs (status = "flat", tilt under 5°).
  • Without a DSM: the orientation of the polygon's minimum rotated rectangle, facing the side closest to south. It gives the axis of the installation only, and can be wrong by 180°.

Azimuths are in degrees, 0 = north, clockwise (90 = east, 180 = south).

Installed capacity

The installed capacity (kWp) is proportional to the surface of the panels: the projected surface of the polygon divided by the cosine of the tilt. The coefficient (regression-type) is either a constant (default-coefficient, 1/6.5 kWp/m²), or calibrated on the BDPV registry shipped with the package: one coefficient (linear) or one per surface class (clustered).

Covered countries

Country / region Service Product Resolution CRS Protocol Licence
France fr-lidar IGN LiDAR HD 0.5 m EPSG:2154 WMS-R Etalab 2.0
France fr-correl IGN MNS Correl (from aerial images, less precise) 0.5 m EPSG:2154 WMS-R Etalab 2.0
Netherlands nl-ahn AHN 0.5 m EPSG:28992 WCS 2.0.1 CC0
Belgium (Flanders) be-flanders DHMV II (2013-2015) 1 m EPSG:31370 WCS 2.0.1 Modellicentie gratis hergebruik
United Kingdom (England) uk-england Environment Agency LiDAR composite DSM 1 m EPSG:27700 WCS 2.0.1 OGL v3
Germany (North Rhine-Westphalia) de-nw DOM1 1 m EPSG:25832 WCS 2.0.1 dl-de/zero-2-0
Germany (Mecklenburg-Vorpommern) de-mv DOM1 1 m EPSG:25833 WCS 2.0.1 CC BY 4.0
Poland pl GUGiK NMPT (slow, ~7 s per polygon) 0.5 m EPSG:2180 WCS 1.0.0 GUGiK
Norway no Nasjonal høydemodell DOM 1 m EPSG:25833 WCS 1.0.0 CC BY 4.0
Switzerland ch-swisssurface3d swisstopo swissSURFACE3D 0.5 m EPSG:2056 STAC + COG swisstopo OGD
Anywhere path to a folder your GeoTIFFs (pixel = elevation in metres) any any projected local files yours

Polygons can be given in any CRS. At 1 m, polygons under about 12 m² have too few pixels to be measured. pypvroof.available_services() returns this table.

Installation

pip install pypvroof

From source: git clone https://github.com/gabrielkasmi/pypvroof.git && cd pypvroof && pip install -e ".[dev]". Python >= 3.10.

Usage

Tilt and azimuth measured on a DSM, for a whole file:

from pypvroof import characterize_roofs

out = characterize_roofs("detections.geojson", "fr-lidar", workers=8)

The input can be a GeoDataFrame, a GeoJSON, a parquet file, a list of shapely polygons... The output is a GeoDataFrame with tilt, azimuth, surface, a status (ok, flat, multimodal, no_coverage, too_few_points...) and the service metadata (meta_*, e.g. the LiDAR acquisition date). No fallback is applied: when a value cannot be measured, status says why and you choose what to do (another service, the heuristics...).

All characteristics, including the installed capacity:

from pypvroof import MetadataExtraction

params = {
    "tilt-method": "theil-sen",      # or "constant"
    "azimuth-method": "theil-sen",   # or "bounding-box"
    "dsm-service": "fr-lidar",            # a service from the table, or a folder of GeoTIFFs
    "regression-type": "linear",     # or "constant", "clustered"
}
df = MetadataExtraction(p=params).extract_all_characteristics("detections.geojson")

Visual check of a polygon (orthophoto and DSMs, pip install "pypvroof[viz]"):

from pypvroof.viz import plot_polygon
fig = plot_polygon(polygon, services=("fr-lidar", "fr-correl"))

See the API documentation for all parameters and statuses.

Contributing: add a service

Your country is not in the table? Most national LiDAR surface models are published as an OGC WCS (or STAC + Cloud-Optimized GeoTIFFs), and adding one is usually a single entry in pypvroof/catalog.py. See CONTRIBUTING.md for the step-by-step guide, then open a pull request.

Citation

@article{tremenbert2023pypvroof,
  title={PyPVRoof: a Python package for extracting the characteristics of rooftop PV installations using remote sensing data},
  author={Tr{\'e}menbert, Yann and Kasmi, Gabriel and Dubus, Laurent and Saint-Drenan, Yves-Marie and Blanc, Philippe},
  journal={arXiv preprint arXiv:2309.07143},
  year={2023}
}

PyPVRoof expands the characteristics extraction module of Kasmi et al. (2022).

License

MIT, see LICENSE. The surface models belong to their producers and are used under their licences (see the table above).

Metadata

Release files for pypvroof 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pypvroof 0.2.0
File Size Uploaded Provenance Actions
pypvroof-0.2.0.tar.gz 193.1 kB Without provenance Details for pypvroof-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pypvroof 0.2.0
File Interpreter ABI Platform Actions
pypvroof-0.2.0-py3-none-any.whl Python 3 none any Details for pypvroof-0.2.0-py3-none-any.whl

Total release size: 381.9 kB

Release files / pypvroof-0.2.0.tar.gz

Download URL pypvroof-0.2.0.tar.gz
Size 193.1 kB
Tags Source
SHA-256 checksum
How to use checksums
d664a40e20f2a0b8b41d9f8ca4ff8e268e8d03990abe6a65fae8ad516eb069a5
BLAKE2b-256 checksum
How to use checksums
540073e19f97a7d639f18b8b3e89ebb5a66f30e9881d94f46adc68f7e25e4014
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.2

Release files / pypvroof-0.2.0-py3-none-any.whl

Download URL pypvroof-0.2.0-py3-none-any.whl
Size 188.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
68a305f53519f26ab891f98583776ac6328b27eb379431d776814ee52652f2c1
BLAKE2b-256 checksum
How to use checksums
015c272c71ae0715a28bed40eafb93ae935b0666c4e3a613928d60a0f9c2e242
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.2

Security for pypvroof 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page