🔬 Dive into the Background Theory
This section provides a deeper look into the data, mathematics, and methodology behind RegionMatch.
You do not need this section to use the plugin. It is intended for users who want to understand how similarity is computed, how data are prepared, and how configuration choices influence the results.
1. Mathematical Description of Similarity
This section describes how RegionMatch translates multidimensional regional characteristics into a single similarity score.
1.1 Feature Selection and Weighting
Let \(A\) denote the set of comparison aspects:
climate
sociodemography
orography
land use
Each aspect \(a \in A\) is associated with a feature vector:
Users assign a numeric weight to each aspect:
Weight \(w_a\) |
Meaning |
|---|---|
1.0 |
high relevance |
0.5 |
medium relevance |
0.0 |
low relevance |
The sum of all weights defines the maximum possible similarity score:
This implies that the scale of the similarity score depends directly on the selected weights.
1.2 Distance Calculation
For each aspect \(a\), the distance between the reference region \(x_0 \in \mathbb{R}^n\) and another region \(x_i \in \mathbb{R}^n\) is computed using the standardised Euclidean distance:
where \(\sigma_j^2\) denotes the variance of feature \(j\) across all regions.
In the implementation, this is computed using:
scipy.spatial.distance.cdist(
target_features,
all_features,
metric="seuclidean",
V=variances,
)
Standardisation ensures that indicators with large numeric ranges do not dominate the distance calculation.
1.3 Similarity Score Construction
Raw distances are transformed into similarity values by normalising and inverting the distance range:
This transformation ensures that:
values close to 1 indicate high similarity
values close to 0 indicate low similarity
Each aspect-specific similarity is then weighted according to user-defined relevance:
with
2. Data Basis
RegionMatch relies on a harmonised table that combines administrative, sociodemographic, land use, orographic, and climate information for all German districts (NUTS3 level).
2.1 Overview of Input Data
Data |
Unit |
Aspect |
Source |
|---|---|---|---|
NUTS_CODE |
n.a. |
Description |
|
NUTS_NAME |
n.a. |
Description |
|
Total area |
km² |
Sociodemographic |
|
Total population |
n.a. |
Sociodemographic |
|
Population density |
1/km² |
Sociodemographic |
|
Population over 65 |
% |
Sociodemographic |
|
Urban & traffic areas |
% |
Land use |
|
Agricultural land |
% |
Land use |
|
Forest area |
% |
Land use |
|
Orography type |
n.a. |
Orography |
|
Hot days |
days |
Climate |
|
Longest dry spell |
days |
Climate |
|
Heavy precipitation days |
days |
Climate |
|
Tropical nights |
days |
Climate |
Climate indicators are based on near-surface values, provided as 30-year means for the historical period and as changes relative to the historical period for +2 °C and +3 °C global warming levels.
3. Climate Indicators
The following climate indicators are used:
Indicator |
Abbreviation |
Definition |
|---|---|---|
Hot days |
TXge30 |
Days with daily maximum temperature ≥ 30 °C |
Tropical nights |
TR |
Days with daily minimum temperature > 20 °C |
Heavy precipitation days |
R30mm |
Days with precipitation ≥ 30 mm |
Longest dry spell |
CDD |
Longest sequence of days with precipitation < 1 mm |
Indicator definitions follow the Climpact standard indices.
4. Spatial Aggregation of Climate Data
German district geometries are derived from NUTS3 shapefiles provided by the Federal Agency for Cartography and Geodesy (german: Bundesamt für Kartografie und Geodäsie). These geometries are converted to GeoJSON and filtered to include only land districts.
The geometries are then used to spatially aggregate climate model output using regionmask, xarray, and cosine-latitude weighting.
This approach allows efficient computation of district-level climate indicators.
5. Orography Classification
Orography is provided as elevation (meters above sea level) in the NUKLEUS model data.
Each district is assigned an orography type based on the maximum elevation within its boundaries:
Type |
Condition |
Code |
|---|---|---|
Lowland |
max < 200 m |
0 |
Upland |
200–500 m |
1 |
Highlands |
500–1500 m |
2 |
High mountains |
≥ 1500 m |
3 |
These numeric codes are used directly in the similarity calculation.
6. Code Structure and Data Updates
6.1 Main Components
run_plugin.py: Core similarity computationutils.py: Visualisation, mapping, and output generationprepare_data.py: Input data preparation
6.2 Updating the Data Basis
Data preparation is decoupled from the plugin logic and handled via scripts in data/.
Running the preparation workflow:
downloads updated sociodemographic and land use data
computes climate indicators
determines orography types
assembles the final input table used by the plugin
This separation ensures reproducibility and easier maintenance.