Skip to content

Repository files navigation

Berlin Budgetary Data

This repository publishes Berlin’s official budgetary data as RDF / Linked Open Data.

The data are prepared from the budget datasets provided by the Senate Department for Finance (Senatsverwaltung für Finanzen). This repository takes the prepared RDF data and generates a browsable Linked Open Data website.

Start browsing the data!

Currently, the dataset contains budgetary data for the years 2022–2027.

Data preparation

The original budget data are published by the Senate Department for Finance (Senatsverwaltung für Finanzen) via the Berlin Open Data Portal. Search for "Doppelhaushalt" to find the relevant datasets.

The source data are prepared using the separate budget2lod repository.

budget2lod processes the source data and generates several RDF datasets in Turtle (TTL) format. These files contain, among other things, the budget titles, chapters, groups, functions and observations.

Before generating the website, the individual TTL files need to be combined into one RDF dataset. The observationset-be.ttl file is excluded from this step, while the haushalt-cube-be.ttl file is added to the combined graph.

The basic workflow is:

Berlin Open Data Portal
        ↓
   budget2lod
        ↓
    RDF / TTL
        ↓
    lod-budget
        ↓
Static Linked Open Data website

Combining the TTL files

The individual TTL files generated by budget2lod can be combined using rdflib.

The following is a simplified example of the required approach:

from rdflib import Graph
import glob

graph = Graph()

for ttl_file in glob.glob("path/to/budget2lod/output/*.ttl"):
    if ttl_file.endswith("observationset-be.ttl"):
        continue

    graph.parse(ttl_file, format="turtle")

graph.parse(
    "path/to/budget2lod/data/haushalt-cube-be.ttl",
    format="turtle"
)

graph.serialize(
    destination="data/haushalt-be.ttl",
    format="turtle"
)

The resulting haushalt-be.ttl file is used as the input dataset for this repository.

Generating the site

The complete TTL dataset is relatively large. Consequently, generating the complete static website can take some time, especially when working with the full dataset.

To generate the static site locally, you need Python 3 and the dependencies listed in requirements.txt.

Create a Python virtual environment:

python3 -m venv .venv

Activate the virtual environment:

source .venv/bin/activate

Install the dependencies:

pip install -r requirements.txt

Create the combined N-Triples dataset:

make data/temp/all.nt

Generate the static website:

make generate

Run the site locally

To generate the website and start a local web server in one step:

make generate+serve_locally

The website is then available at:

http://localhost:8000

Automated deployment

The static website is generated and deployed automatically using GitHub Actions when changes are pushed to the main branch.

The published website is available at:

https://berlin.github.io/lod-budget/

License

All code in this repository is published under the MIT License. All data are published under CC0.

About

Budgetary data for Berlin as RDF / Linked Open Data.

Topics

Resources

Stars

6 stars

Watchers

3 watching

Forks

Releases

Packages

Contributors

Languages