base_network: Add underwater_fraction to links

This commit is contained in:
Jonas Hörsch 2018-08-14 17:01:58 +02:00
parent a3ee75a2a7
commit 4e078002af

View File

@ -260,6 +260,11 @@ def _set_countries_and_substations(n):
return buses
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(loads))
n.links['underwater_fraction'] = links.intersection(offshore_shape).length / links.length
def base_network():
buses = _load_buses_from_eg()
@ -293,6 +298,8 @@ def base_network():
_set_countries_and_substations(n)
_set_links_underwater_fraction(n)
return n
if __name__ == "__main__":