Skip to content

Commit

Permalink
Check if type of geom is a geometry entry
Browse files Browse the repository at this point in the history
  • Loading branch information
ClaraBuettner committed Aug 16, 2024
1 parent f932d49 commit 1f4f317
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions etrago/tools/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 1f4f317

Please sign in to comment.