base_network: underwater_fraction skips links without a geometry

This commit is contained in:
Jonas Hörsch 2018-08-27 14:19:50 +02:00
parent 64e89bfcc1
commit 94c10fc72b

View File

@ -262,7 +262,7 @@ def _set_countries_and_substations(n):
def _set_links_underwater_fraction(n):
offshore_shape = gpd.read_file(snakemake.input.offshore_shapes).set_index('id').unary_union
links = gpd.GeoSeries(n.links.geometry.map(shapely.wkt.loads))
links = gpd.GeoSeries(n.links.geometry.dropna().map(shapely.wkt.loads))
n.links['underwater_fraction'] = links.intersection(offshore_shape).length / links.length
def base_network():