PyPSA/grid-builder

A modular Snakemake workflow for constructing and validating power grid models using OpenStreetMap data.

Overview

Latest release: None, Last update: 2026-09-25

Share link: https://snakemake.github.io/snakemake-workflow-catalog?wf=PyPSA/grid-builder

Quality control: linting: failed formatting: failed

Topics: electricity model openstreetmap power-systems pypsa snakemake

Deployment

Step 1: Install Snakemake and Snakedeploy

Snakemake and Snakedeploy are best installed via the Conda package manager. It is recommended to install conda via Miniforge. Run

conda create -c conda-forge -c bioconda -c nodefaults --name snakemake snakemake snakedeploy

to install both Snakemake and Snakedeploy in an isolated environment. For all following commands ensure that this environment is activated via

conda activate snakemake

For other installation methods, refer to the Snakemake and Snakedeploy documentation.

Step 2: Deploy workflow

With Snakemake and Snakedeploy installed, the workflow can be deployed as follows. First, create an appropriate project working directory on your system and enter it:

mkdir -p path/to/project-workdir
cd path/to/project-workdir

In all following steps, we will assume that you are inside of that directory. Then run

snakedeploy deploy-workflow https://github.com/PyPSA/grid-builder . --tag None

Snakedeploy will create two folders, workflow and config. The former contains the deployment of the chosen workflow as a Snakemake module, the latter contains configuration files which will be modified in the next step in order to configure the workflow to your needs.

Step 3: Configure workflow

To configure the workflow, adapt config/config.yml to your needs following the instructions below.

Step 4: Run workflow

The deployment method is controlled using the --software-deployment-method (short --sdm) argument.

To run the workflow with automatic deployment of all required software via conda/mamba, use

snakemake --cores all --sdm conda

Snakemake will automatically detect the main Snakefile in the workflow subfolder and execute the workflow module that has been defined by the deployment in step 2.

For further options such as cluster and cloud execution, see the docs.

Step 5: Generate report

After finalizing your data analysis, you can automatically generate an interactive visual HTML report for inspection of results together with parameters and code inside of the browser using

snakemake --report report.zip

Configuration

The following section is imported from the workflow’s config/README.md.

Set countries to the ISO country codes that define the retrieval scope. The workflow first loads the default config/config.yaml, then an optional config/regions/config.<ISO>.yaml file for every selected country. A regions mapping in the calling configuration overrides values from those regional files.

retrieve.source picks the retrieval backend: geofabrik reads a cached local PBF extract (retrieve_osm_pbf.py), overpass queries the live Overpass API (retrieve_osm_overpass.py). Both produce the same output shape, so clean doesn’t need to know which one ran. network.include_relations decides whether the network should consider route=power/power=circuit relations, grouping their member ways into one line per real-world circuit; retrieval respects this too, so relations aren’t fetched at all when it’s off. network also controls the minimum retained AC voltage, station merge buffer radius, construction filtering, and planned-asset cutoff date.

The BE+NL example is a small European development scope. Country files under config/regions are intentionally small defaults for now; community-maintained local corrections belong there rather than in workflow code.

interactive_map controls the size of map.html: coordinate_decimals rounds embedded coordinates, and simplify_geometries sets per-geometry-type Douglas-Peucker tolerances (in metres) for station polygons, bus polygons, and lines, or disables simplification entirely via simplify_geometries.enable.

Personal settings and Overpass fair use

Keep config/config.yaml as pure defaults — a test enforces that it matches the schema, and it’s tracked in git, so it’s not the place for anything environment- or person-specific. For local overrides (a custom Overpass endpoint, contact details, a smaller countries scope for development), create an untracked config/config.local.yaml and pass it alongside the default:

snakemake --configfile config/config.local.yaml ...

Snakemake deep-merges it on top of config/config.yaml, so you only need to list the keys you’re overriding.

If you use retrieve.source: overpass, set retrieve.overpass_api.user_agent to your own project name, contact email, and website. The Overpass API fair use policy expects automated queries to be identifiable and reachable; a generic or missing user agent risks being rate-limited or blocked. retrieve.overpass_api.url also lets you point at your own or a faster mirror instance instead of the shared public endpoint, without touching the checked-in default.

The generated schema describes every option.

Linting and formatting

Linting results
1/home/runner/work/snakemake-workflow-catalog/snakemake-workflow-catalog/.pixi/envs/default/lib/python3.13/site-packages/google/auth/transport/grpc.py:43: FutureWarning: grpcio < 1.83.0 does not support Post-Quantum Cryptography (PQC). Support for non-PQC environments is deprecated. In April 2027, google-auth will raise its minimum requirements to enforce grpcio >= 1.83.0. For more details on Google Cloud's post-quantum security migration, visit: https://cloud.google.com/security/resources/post-quantum-cryptography
2  warnings.warn(
3Using workflow specific profile workflow/profiles/default for setting default command line arguments.
4ModuleNotFoundError in file "/tmp/tmp5n3u_i9d/workflow/Snakefile", line 8:
5No module named 'earth_osm'
6  File "/tmp/tmp5n3u_i9d/workflow/Snakefile", line 8, in <module>
7  File "/tmp/tmp5n3u_i9d/workflow/scripts/_schema.py", line 14, in <module>
Formatting results
1[DEBUG] 
2[DEBUG] 
3[DEBUG] 
4[DEBUG] 
5[DEBUG] In file "/tmp/tmp5n3u_i9d/workflow/rules/retrieve.smk":  Formatted content is different from original
6[INFO] 1 file(s) would be changed 😬
7[INFO] 3 file(s) would be left unchanged 🎉
8
9snakefmt version: 0.11.5