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
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 CitDPC 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.
Getting started
This package requires Python ≥ 3.12.
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]"
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}°"
)
For developers
Local development setup
- Clone the repo
git clone https://github.com/ffe-munich/lod2-buildings-downloader.git
- 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
- 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 pytest
# also run the full download pipeline against the live service
pytest --download
# or with uv
uv run 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 ruff check
# apply fixes if possible
uv run ruff check --fix
Formatting
# check formatting
uv run ruff format --check .
# apply formatting
uv run ruff format .
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".
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your Changes (
git commit -m 'Add some AmazingFeature') - Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request
License
Distributed under the MIT License. See LICENSE.md for more information.
Metadata
Release files for lod2-buildings-downloader 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| lod2_buildings_downloader-1.0.0.tar.gz | 138.2 kB | With provenance | Details for lod2_buildings_downloader-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| lod2_buildings_downloader-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for lod2_buildings_downloader-1.0.0-py3-none-any.whl |
Total release size: 275.9 kB
Release files / lod2_buildings_downloader-1.0.0.tar.gz
| Download URL | lod2_buildings_downloader-1.0.0.tar.gz |
|---|---|
| Size | 138.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b942519acf12a112c7143b3c5dd16556cee58d215a170a616963bafed313fcc7
|
|
BLAKE2b-256 checksum How to use checksums |
5e71e5d21ad3a2b6f62379330685ff55ecc4527fe6fdfaba720424a32e785c13
|
| 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 logRelease files / lod2_buildings_downloader-1.0.0-py3-none-any.whl
| Download URL | lod2_buildings_downloader-1.0.0-py3-none-any.whl |
|---|---|
| Size | 137.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
65730d4153c9138513d104b5e770d6aef1df75d1ce86e7fcfef305859bd3aad4
|
|
BLAKE2b-256 checksum How to use checksums |
5f734b92b82775369bdd21e91dc4e40a90b7a7d6c18cc9000ba8590cb20f6597
|
| 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 logSecurity for lod2-buildings-downloader 1.0.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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for lod2_buildings_downloader-1.0.0.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 logA 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.