Rename index column in geojson imports

This commit is contained in:
Jonas Hoersch 2018-12-19 15:37:18 +01:00
parent aa24686517
commit f60c1fdb41
4 changed files with 7 additions and 7 deletions

View File

@ -277,8 +277,8 @@ def _set_countries_and_substations(n):
) )
countries = snakemake.config['countries'] countries = snakemake.config['countries']
country_shapes = gpd.read_file(snakemake.input.country_shapes).set_index('id')['geometry'] country_shapes = gpd.read_file(snakemake.input.country_shapes).set_index('name')['geometry']
offshore_shapes = gpd.read_file(snakemake.input.offshore_shapes).set_index('id')['geometry'] offshore_shapes = gpd.read_file(snakemake.input.offshore_shapes).set_index('name')['geometry']
substation_b = buses['symbol'].str.contains('substation|converter station', case=False) substation_b = buses['symbol'].str.contains('substation|converter station', case=False)
def prefer_voltage(x, which): def prefer_voltage(x, which):
@ -387,7 +387,7 @@ def _replace_b2b_converter_at_country_border_by_link(n):
.format(i, b0, line, linkcntry.at[i], buscntry.at[b1])) .format(i, b0, line, linkcntry.at[i], buscntry.at[b1]))
def _set_links_underwater_fraction(n): def _set_links_underwater_fraction(n):
offshore_shape = gpd.read_file(snakemake.input.offshore_shapes).set_index('id').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

View File

@ -12,8 +12,8 @@ countries = snakemake.config['countries']
n = pypsa.Network(snakemake.input.base_network) n = pypsa.Network(snakemake.input.base_network)
country_shapes = gpd.read_file(snakemake.input.country_shapes).set_index('id')['geometry'] country_shapes = gpd.read_file(snakemake.input.country_shapes).set_index('name')['geometry']
offshore_shapes = gpd.read_file(snakemake.input.offshore_shapes).set_index('id')['geometry'] offshore_shapes = gpd.read_file(snakemake.input.offshore_shapes).set_index('name')['geometry']
onshore_regions = [] onshore_regions = []
offshore_regions = [] offshore_regions = []

View File

@ -13,7 +13,7 @@ cutout = atlite.Cutout(snakemake.config['renewable']['hydro']['cutout'],
cutout_dir=os.path.dirname(snakemake.input.cutout)) cutout_dir=os.path.dirname(snakemake.input.cutout))
countries = snakemake.config['countries'] countries = snakemake.config['countries']
country_shapes = gpd.read_file(snakemake.input.country_shapes).set_index('id')['geometry'].reindex(countries) country_shapes = gpd.read_file(snakemake.input.country_shapes).set_index('name')['geometry'].reindex(countries)
country_shapes.index.name = 'countries' country_shapes.index.name = 'countries'
eia_stats = vhydro.get_eia_annual_hydro_generation(snakemake.input.eia_hydro_generation).reindex(columns=countries) eia_stats = vhydro.get_eia_annual_hydro_generation(snakemake.input.eia_hydro_generation).reindex(columns=countries)

View File

@ -169,7 +169,7 @@ if __name__ == '__main__':
import geopandas as gpd import geopandas as gpd
from shapely.geometry import LineString from shapely.geometry import LineString
offshore_shape = gpd.read_file(snakemake.input.offshore_shapes).set_index('id').unary_union offshore_shape = gpd.read_file(snakemake.input.offshore_shapes).unary_union
underwater_fraction = [] underwater_fraction = []
for i in regions.index: for i in regions.index:
row = layoutmatrix[i] row = layoutmatrix[i]