Skip to main content


lod2-buildings-downloader

Python library for downloading and parsing LoD2 building data from German open-geodata services. Given an area of interest, it connects to the relevant services, retrieves the necessary files and returns structured Building objects.

· Report Bug · Request Feature

Table of Contents
  1. About the project
  2. Prerequisites
  3. Getting started
  4. Usage
  5. For developers
    1. Local development setup
    2. Tests
    3. Code style
  6. Contributing
  7. License

About the project

Germany's LoD2 building data provides 3D geometries for virtually every building in the country. However, each federal state publishes its data through different services and formats, making nationwide usage cumbersome.

This library offers a central, user-friendly solution that downloads LoD2 data for a given area of interest, parses the building geometries, and returns structured Building objects — ready to use for solar potential analysis, urban planning, or any other application that needs roof surface data.

The parsing of CityGML files is heavily powered by the work of the developers and maintainers from the CityDPC project. So thanks for that!

This is a sibling project of orthophotos-downloader and integrates directly with it via the Building.download_orthophoto() method, which instantly downloads an image of the Building - especially usefull for use cases involving computer vison or object detection.

(back to top)

Prerequisites

This package requires Python ≥ 3.12.

(back to top)

Getting started

Ensure to read the Prerequisites section and install the downloader:

pip install lod2-buildings-downloader
# or with uv
uv add lod2-buildings-downloader

With orthophoto support (integrates with orthophotos-downloader):

pip install "lod2-buildings-downloader[orthophotos]"
# or with uv
uv add "lod2-buildings-downloader[orthophotos]"

(back to top)

Usage

from shapely.geometry import Polygon
from lod2_buildings_downloader import BuildingsDownloaderBY

area = Polygon([(690000, 5334000), (690100, 5334000), (690100, 5334100), (690000, 5334100)])
downloader = BuildingsDownloaderBY(area)
buildings = downloader.generate_buildings()

for building in buildings:
    print(building.gml_id)
    print(f"  Grounds: {len(building.grounds)}, Roofs: {len(building.roofs)}")
    for roof in building.roofs:
        print(
            f"  Roof area: {roof.surface_area:.1f} m², tilt: {roof.surface_tilt}°, orientation: {roof.surface_orientation}°"
        )

(back to top)

For developers

Local development setup

  1. Clone the repo
    git clone https://github.com/ffe-munich/lod2-buildings-downloader.git
    
  2. Install all dependencies including the dev dependencies
    # requires pip>=25.1 for --group support
    pip install -e . --group dev
    # or with uv
    uv sync --group dev
    
  3. Optionally install the orthophotos extra along with the dev dependencies
# requires pip>=25.1 for --group support
pip install -e ".[orthophotos]" --group dev
# or with uv
uv sync --group dev --extra orthophotos
  1. Install the CityDPC revision required by this project
pip install "git+https://github.com/ffe-munich/CityDPC.git@main"
# or with uv
uv pip install "git+https://github.com/ffe-munich/CityDPC.git@main"

Important for uv: CityDPC is installed outside uv.lock. After installing it, environment-syncing commands such as uv sync or uv run without --no-sync can remove it. Run subsequent project commands with uv run --no-sync .... Install optional extras before CityDPC.

Tests

The test suite uses pre-downloaded GML fixture files stored in tests/data/ so no network access is required by default.

Because CityDPC is installed separately from the uv lockfile, use uv run --no-sync to keep uv from removing it when running project commands.

Run tests with these commands.

# offline (default) — fast, no network required
pytest
# or with uv
uv run --no-sync pytest

# also run the full download pipeline against the live service
pytest --download
# or with uv
uv run --no-sync pytest --download

Alternatively, when using VSCode you can use the included settings.json example to configure the Python Extension with the Test Explorer integration and run / debug tests from there.

When --download is passed, every integration test is run a second time where it actually connects to the real services and downloads live data. So, in this case the full pipeline is covered by the tests. Unit tests are unaffected by this flag.

Code style

This project uses Ruff for linting and formatting. Its configuration in pyproject.toml sets a 100-character line length and checks for style issues (E), likely mistakes such as unused names (F), warnings (W), and import ordering (I).

Linting

# check for linting issues
uv run --no-sync ruff check

# apply fixes if possible
uv run --no-sync ruff check --fix

Formatting

# check formatting
uv run --no-sync ruff format --check .

# apply formatting
uv run --no-sync ruff format .

(back to top)

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement".

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

License

Distributed under the MIT License. See LICENSE.md for more information.

(back to top)

Metadata

Release files for lod2-buildings-downloader 1.0.1

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

Source distribution (sdist)

Source distribution for lod2-buildings-downloader 1.0.1
File Size Uploaded Provenance Actions
lod2_buildings_downloader-1.0.1.tar.gz 138.7 kB With provenance Details for lod2_buildings_downloader-1.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for lod2-buildings-downloader 1.0.1
File Interpreter ABI Platform Actions
lod2_buildings_downloader-1.0.1-py3-none-any.whl Python 3 none any Details for lod2_buildings_downloader-1.0.1-py3-none-any.whl

Total release size: 277.0 kB

Release files / lod2_buildings_downloader-1.0.1.tar.gz

Download URL lod2_buildings_downloader-1.0.1.tar.gz
Size 138.7 kB
Tags Source
SHA-256 checksum
How to use checksums
c688914616bbfd46a4645ec0671efb64cc82fe4878a1b5fbacf9e818ba853eca
BLAKE2b-256 checksum
How to use checksums
f7d55c1339c582c825dfcc8fdb30be48f6cc55ad699aa16585bc342cf04a03a1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 8, 2026.

Transparency log

Release files / lod2_buildings_downloader-1.0.1-py3-none-any.whl

Download URL lod2_buildings_downloader-1.0.1-py3-none-any.whl
Size 138.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b7b93243727d44b11cf4adea078de654d3614d7d14c7a1c079ee7fd2afc670c1
BLAKE2b-256 checksum
How to use checksums
45d4962c9bf129db9fee2705bae87c12b1ddfb514033cd4cd890117bb0d94254
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 8, 2026.

Transparency log

Security for lod2-buildings-downloader 1.0.1

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for lod2_buildings_downloader-1.0.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 8, 2026.

Transparency log

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