diff --git a/scripts/base_network.py b/scripts/base_network.py index b23fa0c1..f2eab220 100644 --- a/scripts/base_network.py +++ b/scripts/base_network.py @@ -411,10 +411,13 @@ def _replace_b2b_converter_at_country_border_by_link(n): def _set_links_underwater_fraction(n): if n.links.empty: return - - offshore_shape = gpd.read_file(snakemake.input.offshore_shapes).unary_union - links = gpd.GeoSeries(n.links.geometry.dropna().map(shapely.wkt.loads)) - n.links['underwater_fraction'] = links.intersection(offshore_shape).length / links.length + + if not hasattr(n.links, 'geometry'): + n.links['underwater_fraction'] = 0. + else: + offshore_shape = gpd.read_file(snakemake.input.offshore_shapes).unary_union + links = gpd.GeoSeries(n.links.geometry.dropna().map(shapely.wkt.loads)) + n.links['underwater_fraction'] = links.intersection(offshore_shape).length / links.length def _adjust_capacities_of_under_construction_branches(n): lines_mode = snakemake.config['lines'].get('under_construction', 'undef')