{
  "hash": "73b9389aa27ce9c2491920d58bf71791",
  "result": {
    "engine": "jupyter",
    "markdown": "---\ntitle: Animated GIF\ndescription: Example to create a animated GIF showing the principle of **brdr**\nauthor: Karel Dieussaert\ndate: '2026-01-07'\ncategories:\n  - Animation\nformat:\n  html:\n    code-fold: true\n---\n\n# Animated GIF\n\nExample to create a animated GIF showing the principle of **brdr**. For every augmented relevant distance (~distance that adaptions are allowed), the resulting geometry is shown. In the graphic you can 'see' the moments where augmenting relevant distance does not give any change, so stable geometries are found.\n\n::: {#cell-fig-plots .cell execution_count=1}\n``` {.python .cell-code}\nfrom datetime import datetime\n\nimport numpy as np\n\nfrom brdr.aligner import Aligner\nfrom brdr.be.grb.enums import GRBType\nfrom brdr.be.grb.loader import GRBActualLoader\nfrom brdr.loader import GeoJsonLoader\nfrom brdr.viz import animated_map\n\nif __name__ == \"__main__\":\n    # EXAMPLE to process a series of relevant distances\n    # Initiate brdr\n    aligner = Aligner()\n    # Load thematic data\n    geometry = {\n        \"coordinates\": [\n            [\n                [171136.16765265574, 170605.6084498393],\n                [171164.53923982676, 170663.78453262427],\n                [171071.40019103308, 170714.22290981715],\n                [171037.87013346734, 170676.6807086111],\n                [171136.16765265574, 170605.6084498393],\n            ]\n        ],\n        \"type\": \"Polygon\",\n    }\n\n    geometry = {\n        \"coordinates\": [\n            [\n                [171132.08386359326, 170804.71107799126],\n                [171168.04986551206, 170776.33949082025],\n                [171144.2635853586, 170743.09601494312],\n                [171118.32794254067, 170761.58053385757],\n                [171111.52162743648, 170766.9897632298],\n                [171125.34919391124, 170785.6892184107],\n                [171126.13729355487, 170786.83554516506],\n                [171121.9102136481, 170789.8804756064],\n                [171132.08386359326, 170804.71107799126],\n            ]\n        ],\n        \"type\": \"Polygon\",\n    }\n    thematic_json = {\n        \"type\": \"FeatureCollection\",\n        \"name\": \"test\",\n        \"crs\": {\"type\": \"name\", \"properties\": {\"name\": \"urn:ogc:def:crs:EPSG::31370\"}},\n        \"features\": [\n            {\n                \"type\": \"Feature\",\n                \"properties\": {\"fid\": 1100, \"id\": 1100, \"theme_identifier\": \"1100\"},\n                \"geometry\": geometry,\n            }\n        ],\n    }\n\n    loader = GeoJsonLoader(_input=thematic_json, id_property=\"theme_identifier\")\n    aligner.load_thematic_data(loader)\n    # Load reference data: The actual GRB-parcels\n    aligner.load_reference_data(\n        GRBActualLoader(grb_type=GRBType.ADP, partition=1000, aligner=aligner)\n    )\n    # PROCESS a series of relevant distances\n    relevant_distances = np.arange(0, 710, 10, dtype=int) / 100\n    aligner_result = aligner.process(\n        relevant_distances=relevant_distances,\n    )\n    thematic_geometries = {\n        key: feat.geometry for key, feat in aligner.thematic_data.features.items()\n    }\n    reference_geometries = {\n        key: feat.geometry for key, feat in aligner.reference_data.features.items()\n    }\n    # SHOW results: map and plotted changes\n    now = datetime.now()  # current date and time\n    date_time = now.strftime(\"%m_%d_%Y_%H_%M_%S\")\n    # filename = \"animation_\" + str(date_time) + \".gif\"\n    filename = \"animation.gif\"\n    animated_map(\n        aligner_result.results,\n        thematic_geometries,\n        reference_geometries,\n        relevant_distances[-1],\n        25,\n        150,\n        filename,\n    )\n```\n\n::: {.cell-output .cell-output-stderr}\n```\n/home/vermeyma/wf/brdr/brdr/viz.py:77: UserWarning: The GeoSeries you are attempting to plot is composed of empty geometries. Nothing has been displayed.\n  gpd.GeoSeries(list(results_diff_pos.values())).plot(\n/home/vermeyma/wf/brdr/brdr/viz.py:80: UserWarning: The GeoSeries you are attempting to plot is composed of empty geometries. Nothing has been displayed.\n  gpd.GeoSeries(list(results_diff_neg.values())).plot(\n/home/vermeyma/wf/brdr/brdr/viz.py:77: UserWarning: The GeoSeries you are attempting to plot is composed of empty geometries. Nothing has been displayed.\n  gpd.GeoSeries(list(results_diff_pos.values())).plot(\n/home/vermeyma/wf/brdr/brdr/viz.py:80: UserWarning: The GeoSeries you are attempting to plot is composed of empty geometries. Nothing has been displayed.\n  gpd.GeoSeries(list(results_diff_neg.values())).plot(\n```\n:::\n\n::: {.cell-output .cell-output-stdout}\n```\nAnimation successfully saved to: animation.gif\n```\n:::\n\n::: {.cell-output .cell-output-display}\n![Graphic](example_animation_files/figure-html/fig-plots-output-3.png){#fig-plots width=1091 height=470}\n:::\n:::\n\n\n",
    "supporting": [
      "example_animation_files"
    ],
    "filters": [],
    "includes": {}
  }
}