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:
commit
7a18740cfb
@ -412,6 +412,9 @@ 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
|
||||||
|
|
||||||
|
if not hasattr(n.links, 'geometry'):
|
||||||
|
n.links['underwater_fraction'] = 0.
|
||||||
|
else:
|
||||||
offshore_shape = gpd.read_file(snakemake.input.offshore_shapes).unary_union
|
offshore_shape = gpd.read_file(snakemake.input.offshore_shapes).unary_union
|
||||||
links = gpd.GeoSeries(n.links.geometry.dropna().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
|
n.links['underwater_fraction'] = links.intersection(offshore_shape).length / links.length
|
||||||
|
Loading…
Reference in New Issue
Block a user