CH NEO-ZÜRICH EDITION
WEATHER · ACID RAIN 5°C
BLEND OF THE DAY · 07/ROGUE
EST. 2027
THE AEC CYBER MORNING NEWS

PAZ Kaffi

DESIGN · DEMOLITION · CAFFEINE · DISPATCH
EDITION 1122 · 22 November 2026
BROADCAST 04:42 CET
2,400 BROADSHEETS PRINTED
READ TIME · 47 MIN
One Roof, Four Answers: Read Every Sonnendach Roof Face in 49 Lines of Python
ACADEMY
FRAME · 06:50
22-11-2026

One Roof, Four Answers: Read Every Sonnendach Roof Face in 49 Lines of Python

Turn a Swiss address into every Sonnendach roof face: tilt, azimuth, irradiation, class, kWh/a and winter share, via two geo.admin.ch calls in Python.

A roof is not one surface. It is a set of faces, and each face has its own sun. The south slope that catches the low January light, the east slope that wakes up early, the north slope that mostly watches: they are four different answers to the question every client asks, “is our roof good for solar?”. Someone has already computed all of them. For every building in Switzerland, the Bundesamt für Energie (BFE) publishes Sonnendach.ch, and its layer legend on geo.admin.ch names MeteoSwiss irradiation data and swisstopo’s swissBUILDINGS3D 2.0 roof geometry as the sources. The map shows you one face at a time. The public API hands you all of them at once.

This tutorial turns an address into a per-face table in 49 lines of standard-library Python. Two calls to geo.admin.ch, two asserts that re-check BFE’s own rules, one table for the meeting-room screen. No packages, no API key, no CAD.

←TODAY: Sonnendach rates every Swiss roof face per square metre, Datenstand 21.02.2023, at an assumed 20 % module efficiency.
→3012: The roofs still producing are the ones whose data model anyone can open in a text editor.
Fulcrum: An open, documented data model turns a federal map into a building-by-building conversation in your office.

The Tool: The geo.admin.ch REST API, run by swisstopo, serving the BFE layer ch.bfe.solarenergie-eignung-daecher. Behind it sit people whose names rarely appear on a roof: the BFE team who wrote the data model, the MeteoSwiss climatologists who averaged irradiation over 2004–2014 and 2011–2020 with shading included, and the swisstopo surveyors who modelled every roof in 3D. The BFE’s Dokumentation Geodatenmodell Solarenergie: Eignung Dächer, version 1.5 of 31.01.2023, documents every attribute in plain German. That document is the real tool: once you can read a data model, you stop trusting black boxes and start checking them.

Setup:

python --version          # 3.10 or newer; nothing to pip install
mkdir sonnendach
cd sonnendach
# save the program below as sonnendach.py, then:
python -I sonnendach.py "Rathausplatz 1 Frauenfeld"
# -I runs Python isolated: no stray local modules get imported

First steps:

  1. Create the folder and save the program below as sonnendach.py.
  2. Run it with the sample address. You should see a header line with E/N coordinates and an EGID, a check line, then the table.
  3. Run it again with your current project’s address in quotes. Same table, your roof.
  4. Change MIN_M2 from 10 to 30 and watch the dormers and slivers drop out.

The code, explained:

# Which roof faces of this building are worth PV? Sonnendach.ch via geo.admin.ch, standard library only
import json, sys, urllib.parse, urllib.request

sys.stdout.reconfigure(encoding="utf-8")
ADDRESS = sys.argv[1] if len(sys.argv) > 1 else "Rosengartenstrasse 1 Zürich"
MIN_M2 = 10                      # skip dormers, chimneys, tiny slivers
API = "https://api3.geo.admin.ch/rest/services/api"
CLASS = {1: "gering", 2: "mittel", 3: "gut", 4: "sehr gut", 5: "hervorragend"}
LIMITS = [800, 1000, 1200, 1400]  # kWh/m2/a class limits (BFE data model v1.5, Tabelle 6)

def get(path, **params):
    url = f"{API}/{path}?{urllib.parse.urlencode(params)}"
    with urllib.request.urlopen(url, timeout=30) as r:
        return json.load(r)

# 1. address -> LV95 point + federal building id (EGID)
hit = get("SearchServer", searchText=ADDRESS, type="locations", sr=2056, limit=1)["results"][0]["attrs"]
e, n = hit["y"], hit["x"]                 # careful: geo.admin returns East in "y", North in "x"
egid = int(hit["featureId"].split("_")[0])
print(f"{hit['label'].replace('<b>', '').replace('</b>', '')}  E {e:.0f} / N {n:.0f}  EGID {egid}")

# 2. every Sonnendach roof face in a 120 m box, keep this building's faces only
box = f"{e-60},{n-60},{e+60},{n+60}"
res = get("MapServer/identify", geometryType="esriGeometryEnvelope", geometry=box,
          layers="all:ch.bfe.solarenergie-eignung-daecher", sr=2056,
          returnGeometry="false", tolerance=0, limit=200)["results"]
roofs = [r["attributes"] for r in res
         if r["attributes"].get("gwr_egid") == egid and r["attributes"]["flaeche"] >= MIN_M2]

# 3. trust, but verify: class from irradiation, yield = 0.20 module x 0.80 PR x irradiation
for a in roofs:
    assert a["klasse"] == 1 + sum(a["mstrahlung"] >= L for L in LIMITS), a["df_nummer"]
    assert abs(a["stromertrag"] - 0.16 * a["gstrahlung"]) <= 1, a["df_nummer"]
print(f"{len(roofs)} faces >= {MIN_M2} m2; class and kWh rule re-checked on every face")

# 4. one line per face, best first (azimuth: 0 = south, -90 = east, 90 = west, +-180 = north)
print(f"\n{'face':>5} {'m2':>5} {'tilt':>4} {'azim':>5} {'kWh/m2':>6}  {'class':<12} {'kWh/a':>7} {'winter':>6}")
for a in sorted(roofs, key=lambda a: -a["mstrahlung"]):
    print(f"{a['df_nummer']:>5} {a['flaeche']:5.0f} {a['neigung']:4d} {a['ausrichtung']:5d} "
          f"{a['mstrahlung']:6d}  {CLASS[a['klasse']]:<12} {a['stromertrag']:7.0f} "
          f"{a['stromertrag_winterhalbjahr'] / a['stromertrag']:6.0%}")

# 5. the office answer: what do we get if we only cover faces rated 'gut' or better?
for label, group in (("all faces", roofs), ("gut or better", [a for a in roofs if a["klasse"] >= 3])):
    m2 = sum(a["flaeche"] for a in group)
    kwh = sum(a["stromertrag"] for a in group)
    win = sum(a["stromertrag_winterhalbjahr"] for a in group)
    print(f"{label:<14}: {len(group):2d} faces {m2:6.0f} m2 {kwh:8.0f} kWh/a "
          f"= {kwh / m2:4.0f} kWh/m2 module area, winter half-year {win / kwh:.0%}")

Lines 1–14 — constants and one helper: Everything you might tune sits at the top as a named constant: the address (from the command line if you pass one), the minimum face size, the class names, and the four class limits from Tabelle 6 of the BFE data model. The function get (a named piece of code you can call again with different inputs) builds a URL, opens it and parses the JSON reply into Python dictionaries. We call it twice.

Lines 16–20 — address to building: The SearchServer turns free text into a point in LV95 (EPSG 2056, the Swiss coordinate system) plus the EGID, the federal building identifier from the GWR register. Here is the gotcha every beginner hits: geo.admin returns East in the field called y and North in x, following the Swiss surveying convention. Swap them and your box lands somewhere in the Alps. The tell: East in LV95 starts with 2 and has seven digits (2,709,787 for Frauenfeld), North starts with 1 (1,268,234). The EGID hides in featureId as 9083089_0, so we split at the underscore.

Lines 22–28 — every face, then only ours: identify asks the Sonnendach layer for every roof face inside a 120 m square around the point, attributes only. Neighbours come along too, so a list comprehension (a one-line loop that builds a filtered list) keeps only faces whose gwr_egid matches ours and that reach MIN_M2. According to the BFE data model, when several GWR records match one 3D building, one is picked at random, so on terraced blocks expect the occasional surprise.

Lines 30–34 — trust, but verify: An assert stops the program if a statement is false. The first rebuilds the class from mean irradiation: count how many of the four limits the face reaches, add one. The second restates the yield rule, which the BFE documentation defines with a module efficiency (Modul-Wirkungsgrad) of 20 % and a performance ratio of 80 %: 0.2 × 0.8 = 0.16, times the face’s total annual irradiation. BFE reports that the efficiency assumption was raised from 17 % to 20 %, with yields recomputed for all of Switzerland. If an assert ever fires, you have found a data update or a bug in your reading; both are worth knowing. On the Frauenfeld run, all faces passed.

Lines 36–41 — the table: One row per face, best irradiation first. Azimuth follows the BFE convention: 0° south, −90° east, 90° west, ±180° north. Tilt 0 means flat. Area is the inclined roof area, and therefore the maximum module area. The last column divides winter half-year yield (1 October to 31 March) by annual yield. The real output for Rathausplatz 1, 8500 Frauenfeld, EGID 9083089:

 face    m2 tilt  azim kWh/m2  class          kWh/a winter
    2   104   33    19   1385  sehr gut       23119    31%
    3    48   39   -71   1153  gut             8814    27%
    1    48   39   109    966  mittel          7376    25%
    4    82   34  -161    771  gering         10115    18%
all faces     :  4 faces    282 m2    49424 kWh/a =  175 kWh/m2 module area, winter half-year 27%
gut or better :  2 faces    152 m2    31933 kWh/a =  210 kWh/m2 module area, winter half-year 30%

The south face, 104 m², tilted 33° and turned 19° towards west, gets 1,385 kWh/m² and makes 31 % of its electricity in the winter half. The north face gets 771 and only 18 %. The winter sun stands low; a steep south slope meets it closer to square-on, a north slope at a grazing angle or not at all.

Lines 43–49 — the office answer: Two groups, the same three sums. Covering only the two faces rated “gut” or better uses 152 of 282 m² (54 %) but gives 31,933 of 49,424 kWh/a (65 %). The ratio kWh per m² of module area is our own quick indicator, not a BFE one. The beginner mistake here is counting face numbers instead of faces: on a large flat-roof block such as Limmatstrasse 264 in Zürich, one EGID spans two 3D buildings and two faces are both numbered “1”. len(group) counts rows, so the script never relies on the numbers.

Now the limits, plainly. These are modelled potentials, Datenstand 21.02.2023 with partial updates since; not a measured yield and not an offer. Sonnendach knows nothing about fire-brigade paths, edge setbacks, heritage rules, roof structure or your tariff, and a clean table can make a client forget all five. Its authors documented their own edges, which is exactly why you can check them. The API returns JSON and the rules live in a PDF; a 25-year-old in 2051 will still be able to open both, and from where I sit that decides whether a building gets repaired or replaced.

Atelier: A Swiss studio usually meets this question in the first client meeting, with a screenshot of one map face and a hand wave. The per-face table, winter column included, moves that conversation from “is the roof good?” to “which faces, and for which season?”. Monday move: save sonnendach.py into the project template folder and make the table a standing item of the Vorprojekt brief.

Hack: Narrow the office answer to the single best class and predict the result before you run it. On line 44, change a["klasse"] >= 3 to >= 4 and the label to "sehr gut+". For Frauenfeld you should now see one face, 104 m², 23,119 kWh/a, about 222 kWh/m² module area and a 31 % winter share. If your numbers match your prediction, you understand the filter.

for label, group in (("all faces", roofs),
                     ("sehr gut+", [a for a in roofs if a["klasse"] >= 4])):
    m2 = sum(a["flaeche"] for a in group)
    kwh = sum(a["stromertrag"] for a in group)

The API swaps x and y so you never get bored. Everything else in this script is reading carefully, which is the whole craft. If you want that habit inside Archicad too, PAZ teaches it in the Archicad Python Automatisierung course.

Learn-it:

Run it on the address of the project on your desk today, and bring the table, winter column first, to the next client meeting.

FILED FROM
CO-SIGNERS
PAZ Academy
CONFIDENCE
HIGH
REPRINTS
© PAZ - PARAMETRIC ACADEMY ZURICH · ALL RIGHTS RESERVED

PAZ Kaffi · multidisciplinary editorial, led by PAZ Academy

⚑ REPORT AN ERROR · SUBMIT A CORRECTION
◂ BACK TO FRONT PAGE · PAZ KAFFI

© 2026 PAZ Academy.