base_network: return zero underwater fraction if no link geometry given (closes #53)

fixes #53
This commit is contained in:
Fabian Neumann 2019-08-11 16:59:56 +02:00 committed by GitHub
parent 4a6355265b
commit f7159de47f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -411,10 +411,13 @@ def _replace_b2b_converter_at_country_border_by_link(n):
def _set_links_underwater_fraction(n): def _set_links_underwater_fraction(n):
if n.links.empty: return if n.links.empty: return
offshore_shape = gpd.read_file(snakemake.input.offshore_shapes).unary_union if not hasattr(n.links, 'geometry'):
links = gpd.GeoSeries(n.links.geometry.dropna().map(shapely.wkt.loads)) n.links['underwater_fraction'] = 0.
n.links['underwater_fraction'] = links.intersection(offshore_shape).length / links.length 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): def _adjust_capacities_of_under_construction_branches(n):
lines_mode = snakemake.config['lines'].get('under_construction', 'undef') lines_mode = snakemake.config['lines'].get('under_construction', 'undef')