Skip to main content

buildingdata

PyPI Python

Data-management layer for buildingmodel. buildingdata delivers clean, ready-to-use building, demographic and weather datasets for French building energy inference, and caches everything locally so repeated calls don't re-download.

pip install buildingdata

Quick start

import buildingdata as bd

# One-time configuration (bucket, cache dir, credentials).
# The public bucket works anonymously, so this is optional.
bd.configure()

# Reference datasets (downloaded once from Google Cloud Storage, then cached)
census    = bd.get_census()        # INSEE census            -> polars DataFrame
districts = bd.get_districts()     # IRIS district geometry  -> geopandas GeoDataFrame
diagnosis = bd.get_diagnosis()     # ADEME energy diagnoses  -> polars DataFrame
gas       = bd.get_gas_network()   # GRDF gas network routes -> geopandas GeoDataFrame

# On-demand datasets (fetched live from public APIs)
buildings = bd.get_bdtopo("751010101")           # per-IRIS building geometry (IGN WFS)
epw       = bd.get_era5_climate(48.85, 2.35, 2020)  # ERA5 weather -> synthetic EPW

You can also configure from the command line:

buildingdata configure --bucket my-bucket --cache-dir ~/.cache/buildingdata

What it provides

Function Source Returns
get_census() INSEE census (GCS) polars DataFrame
get_districts() IRIS geometries (GCS) geopandas GeoDataFrame
get_diagnosis() ADEME energy performance diagnoses (GCS) polars DataFrame
get_gas_network() GRDF gas network routes (GCS) geopandas GeoDataFrame
get_bdtopo(iris_code) IGN Géoplateforme WFS (live) geopandas GeoDataFrame
get_era5_climate(lat, lon, year) Copernicus CDS (live) path to EPW file

Reference datasets are pulled from a public Google Cloud Storage bucket and cached locally with generation-based freshness checks. French geospatial data uses CRS EPSG:2154 (Lambert-93).

Bulk prefetch for large-scale simulations

The live APIs fetch one IRIS or one grid point at a time. For campaigns over thousands of IRIS, prefetch whole years and départements into the local cache once, then read them lock-free from any number of parallel workers:

buildingdata configure --cds-key YOUR-CDS-KEY   # ERA5 needs Copernicus CDS credentials
buildingdata prefetch era5   --years 2019       # ~1.5 GB/year; one Zarr store over metropolitan France
buildingdata prefetch bdtopo --departments 75 92  # IGN 7z -> per-département GeoParquet
buildingdata cache info                          # sizes + completed bulk partitions
import buildingdata as bd

# After the prefetch, the same functions read the bulk cache automatically:
buildings = bd.get_bdtopo("751010101")                 # source="auto" by default
frame     = bd.get_era5_frame(48.85, 2.35, year=2019)  # EPW-format DataFrame, no EPW file

# Many IRIS at once — one partition scan + spatial join per département
frames = bd.get_bdtopo_bulk(["751010101", "751010102", "920020101"])

# Or force the local cache (fails fast instead of hitting the network):
buildings = bd.get_bdtopo("751010101", source="bulk")

BDTOPO bulk prefetch needs the bulk extra (pip install "buildingdata[bulk]"), ERA5 the era5 extra. See the documentation page Bulk prefetch for large-scale simulations for source selection ("auto"/"bulk"/"wfs"/"cds"), disk sizes, concurrency guarantees and BDTOPO vintage notes.

Configuration

Settings are resolved in the following precedence order:

  1. Explicit function arguments / CLI options
  2. Environment variables (BUILDINGDATA_BUCKET, BUILDINGDATA_CACHE_DIR, GOOGLE_APPLICATION_CREDENTIALS)
  3. Global configuration file (~/.config/buildingdata/config.ini)
  4. Dynamic defaults

Configurable settings:

  • bucket — GCS bucket holding reference datasets (default: building-inference-data)
  • cache directory — where downloaded data is stored locally
  • credentials — path to a GCS service-account JSON (omit for anonymous access to the public bucket)

Cache Behavior & Multi-Project Sharing

  • Default (Unconfigured): The cache directory is namespaced per installation (~/.local/share/buildingdata/cache/<install-id> on Linux/macOS). Each virtualenv or package installation receives its own unique cache subfolder to prevent collisions between environments.
  • Sharing Across Projects: To share a single cache directory across multiple repositories, virtualenvs, or Snakemake pipelines, set the BUILDINGDATA_CACHE_DIR environment variable or write a global configuration file:
# Via CLI (writes ~/.config/buildingdata/config.ini):
buildingdata configure --cache-dir /path/to/shared/cache

# Or via environment variable:
export BUILDINGDATA_CACHE_DIR="/path/to/shared/cache"

Because ~/.config/buildingdata/config.ini is stored in your home directory, configuring it once applies globally to all projects and virtual environments for your user account.

Installation extras

pip install "buildingdata[era5]"   # ERA5 weather (cdsapi, xarray, pvlib, ...)
pip install "buildingdata[bulk]"   # BDTOPO bulk prefetch (py7zr)
pip install "buildingdata[docs]"   # build the Sphinx documentation

Requires Python ≥ 3.10.

License

Released under the MIT License.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

buildingdata-0.4.0.tar.gz (66.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

buildingdata-0.4.0-py3-none-any.whl (79.9 kB view details)

Uploaded Python 3

File details

Details for the file buildingdata-0.4.0.tar.gz.

File metadata

  • Download URL: buildingdata-0.4.0.tar.gz
  • Upload date:
  • Size: 66.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.13

File hashes

Hashes for buildingdata-0.4.0.tar.gz
Algorithm Hash digest
SHA256 adbda0853e67e169751c6c14e0d9184b8d300ba9038bc8bc716a2d8749b9370b
MD5 df000518d34ee8200ba24fc3571f557f
BLAKE2b-256 78cea8106b84ac33dc71c706b5840905bd02b18677574910f8e1c7c379ce4b87

See more details on using hashes here.

File details

Details for the file buildingdata-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: buildingdata-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 79.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.13

File hashes

Hashes for buildingdata-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 da0ae1520a786055b66257062c130377da5f2e099886d9ebced1ede28d8c689c
MD5 3b7440ac960b22ab70cf50db743a3a44
BLAKE2b-256 3cb27bab5241e2bb05b5118ea675a03a57c03ec1eaa87050756e4e249f1ed50b

See more details on using hashes here.

Release history Release notifications | RSS feed

0.6.0

2 files

0.5.0

2 files

This release

0.4.0 This release

2 files

0.3.0

2 files

0.2.2

2 files

0.2.1

2 files

0.2.0

2 files

0.1.1

1 file

0.1.0

1 file

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