build_bus_regions fix index column name to 'name'
This commit is contained in:
parent
7a18740cfb
commit
26453a27bb
@ -24,16 +24,18 @@ for country in countries:
|
|||||||
onshore_shape = country_shapes[country]
|
onshore_shape = country_shapes[country]
|
||||||
onshore_locs = n.buses.loc[c_b & n.buses.substation_lv, ["x", "y"]]
|
onshore_locs = n.buses.loc[c_b & n.buses.substation_lv, ["x", "y"]]
|
||||||
onshore_regions.append(gpd.GeoDataFrame({
|
onshore_regions.append(gpd.GeoDataFrame({
|
||||||
|
'name': onshore_locs.index,
|
||||||
'x': onshore_locs['x'],
|
'x': onshore_locs['x'],
|
||||||
'y': onshore_locs['y'],
|
'y': onshore_locs['y'],
|
||||||
'geometry': voronoi_partition_pts(onshore_locs.values, onshore_shape),
|
'geometry': voronoi_partition_pts(onshore_locs.values, onshore_shape),
|
||||||
'country': country
|
'country': country
|
||||||
}, index=onshore_locs.index))
|
}))
|
||||||
|
|
||||||
if country not in offshore_shapes.index: continue
|
if country not in offshore_shapes.index: continue
|
||||||
offshore_shape = offshore_shapes[country]
|
offshore_shape = offshore_shapes[country]
|
||||||
offshore_locs = n.buses.loc[c_b & n.buses.substation_off, ["x", "y"]]
|
offshore_locs = n.buses.loc[c_b & n.buses.substation_off, ["x", "y"]]
|
||||||
offshore_regions_c = gpd.GeoDataFrame({
|
offshore_regions_c = gpd.GeoDataFrame({
|
||||||
|
'name': offshore_locs.index,
|
||||||
'x': offshore_locs['x'],
|
'x': offshore_locs['x'],
|
||||||
'y': offshore_locs['y'],
|
'y': offshore_locs['y'],
|
||||||
'geometry': voronoi_partition_pts(offshore_locs.values, offshore_shape),
|
'geometry': voronoi_partition_pts(offshore_locs.values, offshore_shape),
|
||||||
@ -45,9 +47,8 @@ for country in countries:
|
|||||||
def save_to_geojson(s, fn):
|
def save_to_geojson(s, fn):
|
||||||
if os.path.exists(fn):
|
if os.path.exists(fn):
|
||||||
os.unlink(fn)
|
os.unlink(fn)
|
||||||
df = s.reset_index()
|
schema = {**gpd.io.file.infer_schema(s), 'geometry': 'Unknown'}
|
||||||
schema = {**gpd.io.file.infer_schema(df), 'geometry': 'Unknown'}
|
s.to_file(fn, driver='GeoJSON', schema=schema)
|
||||||
df.to_file(fn, driver='GeoJSON', schema=schema)
|
|
||||||
|
|
||||||
save_to_geojson(pd.concat(onshore_regions), snakemake.output.regions_onshore)
|
save_to_geojson(pd.concat(onshore_regions), snakemake.output.regions_onshore)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user