Skip to main content


lod2-buildings-downloader

PyPI version Python versions License

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)

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

Tests

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

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.4

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.4
File Size Uploaded Provenance Actions
lod2_buildings_downloader-1.0.4.tar.gz 138.7 kB With provenance Details for lod2_buildings_downloader-1.0.4.tar.gz

Built distribution (wheel)

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

Total release size: 276.8 kB

Release files / lod2_buildings_downloader-1.0.4.tar.gz

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

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 30, 2026.

Transparency log

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

Download URL lod2_buildings_downloader-1.0.4-py3-none-any.whl
Size 138.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2ff1d84a15de7039c430bd23864d54fd4429ecb42faba817a506b56dc366e4d4
BLAKE2b-256 checksum
How to use checksums
19a18a4180fa52cacc2eb72574e01225256964b59c765066d12ef8f2113ce9b0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 30, 2026.

Transparency log

Security for lod2-buildings-downloader 1.0.4

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.4.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 30, 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