GeoDataFrameLoader + GeoPandas Workflow

Loader
GeoDataFrameLoader
GeoPandas
Process
Load thematic and reference geometries from GeoDataFrames and export brdr results back to GeoDataFrame
Author

Karel Dieussaert

Published

March 31, 2026

GeoDataFrameLoader + GeoPandas

This example shows a full in-memory GeoPandas workflow:

  1. Build thematic and reference GeoDataFrame objects.
  2. Load both datasets with GeoDataFrameLoader from the loader API.
  3. Run aligner.process(...).
  4. Export output with aligner_result.get_results_as_geodataframe(...).

Use this pattern when your data pipeline already works in GeoPandas and you want to keep processing in-memory.

import geopandas as gpd
from shapely import from_wkt

from brdr.aligner import Aligner
from brdr.loader import GeoDataFrameLoader


if __name__ == "__main__":
    """Example: use GeoDataFrameLoader for thematic/reference and export results as GeoDataFrame."""

    thematic_gdf = gpd.GeoDataFrame(
        {
            "theme_id": ["t1", "t2"],
            "name": ["theme-one", "theme-two"],
            "geometry": [
                from_wkt("POLYGON ((0 0, 0 9, 5 10, 10 0, 0 0))"),
                from_wkt("POLYGON ((20 0, 20 8, 28 8, 28 0, 20 0))"),
            ],
        },
        geometry="geometry",
        crs="EPSG:31370",
    )

    reference_gdf = gpd.GeoDataFrame(
        {
            "ref_id": ["r1", "r2"],
            "source": ["synthetic", "synthetic"],
            "geometry": [
                from_wkt("POLYGON ((0 1, 0 10, 8 10, 10 1, 0 1))"),
                from_wkt("POLYGON ((21 1, 21 7, 27 7, 27 1, 21 1))"),
            ],
        },
        geometry="geometry",
        crs="EPSG:31370",
    )

    aligner = Aligner(crs="EPSG:31370")
    aligner.load_thematic_data(
        GeoDataFrameLoader(id_property="theme_id", _input=thematic_gdf)
    )
    aligner.load_reference_data(
        GeoDataFrameLoader(
            id_property="ref_id",
            _input=reference_gdf,
            is_reference=True,
        )
    )

    relevant_distances = [0.5, 1.0]
    aligner_result = aligner.process(relevant_distances=relevant_distances)

    result_gdf = aligner_result.get_results_as_geodataframe(
        aligner=aligner,
        add_metadata=False,
        add_original_attributes=True,
    )

    print("rows:", len(result_gdf))
    print("columns:", list(result_gdf.columns))
    print(
        result_gdf[
            [
                "brdr_id",
                "relevant_distance",
                "name",
                "result",
            ]
        ]
    )
rows: 4
columns: ['brdr_id', 'relevant_distance', 'name', 'result', 'properties__brdr_remark', 'properties__brdr_id', 'properties__brdr_nr_calculations', 'properties__brdr_relevant_distance', 'properties__brdr_sym_diff_area_index', 'properties__brdr_sym_diff_area_index_perc', 'properties__brdr_diff_area_index', 'properties__brdr_diff_area_index_perc', 'properties__brdr_diff_length_index', 'properties__brdr_diff_length_index_perc', 'result_diff', 'result_diff_plus', 'result_diff_min', 'result_relevant_intersection', 'result_relevant_diff']
  brdr_id  relevant_distance       name  \
0      t1                0.5  theme-one   
1      t1                1.0  theme-one   
2      t2                0.5  theme-two   
3      t2                1.0  theme-two   

                                              result  
0              POLYGON ((0 0, 0 9, 5 10, 10 0, 0 0))  
1  POLYGON ((0.293 0.293, 0.169 0.444, 0.076 0.61...  
2           POLYGON ((20 0, 20 8, 28 8, 28 0, 20 0))  
3  POLYGON ((20.169 7.556, 20.293 7.707, 20.444 7...  

<- Back to examples overview