From 1f4f31744543574b8f3f98c03316a999009c43f0 Mon Sep 17 00:00:00 2001 From: ClaraBuettner Date: Fri, 16 Aug 2024 14:22:50 +0200 Subject: [PATCH] Check if type of geom is a geometry entry --- etrago/tools/utilities.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/etrago/tools/utilities.py b/etrago/tools/utilities.py index 628c2a48..df8e6058 100755 --- a/etrago/tools/utilities.py +++ b/etrago/tools/utilities.py @@ -29,8 +29,8 @@ import math import os -from geoalchemy2.shape import to_shape # noqa: F401 from pyomo.environ import Constraint, PositiveReals, Var +import geoalchemy2 import numpy as np import pandas as pd import pypsa @@ -1126,9 +1126,16 @@ def agg_parallel_lines(l0): lines_2["bus0"] = bus_max lines_2["bus1"] = bus_min lines_2.reset_index(inplace=True) + lines_2["geom"] = lines_2.apply( - lambda x: None if x.geom is None else x.geom.wkt, axis=1 + lambda x: ( + x.geom.wkt + if isinstance(x.geom, geoalchemy2.elements.WKBElement) + else None + ), + axis=1, ) + network.lines = ( lines_2.groupby(["bus0", "bus1"]) .apply(agg_parallel_lines)