Merge pull request #66 from PyPSA/fneum-patch-1

base_network: return zero underwater fraction if no link geometry given
This commit is contained in:
Jonas Hörsch 2019-08-12 10:52:29 +02:00 committed by GitHub
commit 7a18740cfb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -412,9 +412,12 @@ 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')