Rule build_bus_regions¶
Workflow Diagram
See the complete workflow in the repository.
digraph snakemake_dag { graph [bgcolor=white, margin=0, size="8,5" ]; node [fontname=sans, fontsize=10, penwidth=2, shape=box, style=rounded ]; edge [color=grey, penwidth=2 ]; 3 [color="0.25 0.6 0.85", label=simplify_network]; 4 [color="0.50 0.6 0.85", label=add_electricity]; 5 [color="0.36 0.6 0.85", fillcolor=gray, label=build_bus_regions, style=filled]; 5 -> 3; 5 -> 4; 9 [color="0.22 0.6 0.85", label=build_renewable_profiles]; 5 -> 9; 6 [color="0.58 0.6 0.85", label=base_network]; 6 -> 5; 8 [color="0.28 0.6 0.85", label=build_shapes]; 8 -> 5; }
Script Documentation¶
Creates Voronoi shapes for each bus representing both onshore and offshore regions.
Relevant Settings¶
.. code:: yaml
countries:
.. seealso::
Documentation of the configuration file config.yaml at
:ref:toplevel_cf
Inputs¶
resources/country_shapes.geojson: confer :ref:shapesresources/offshore_shapes.geojson: confer :ref:shapesnetworks/base.nc: confer :ref:base
Outputs¶
-
resources/regions_onshore.geojson:.. image:: /img/regions_onshore.png :width: 33 %
-
resources/regions_offshore.geojson:.. image:: /img/regions_offshore.png :width: 33 %
Description¶
voronoi(points, outline, geo_crs='EPSG:4326')
¶
Create Voronoi polygons from a set of points within an outline.
Parameters¶
points : pd.DataFrame DataFrame containing the coordinates of the points with columns ["x", "y"] and index outline : Polygon Shapely Polygon defining the outline within which to compute the Voronoi partition. geo_crs : str CRS used for geographic projection, passed to GeoPandas (e.g. "EPSG:4326")
Returns¶
gpd.GeoSeries
GeoSeries of Voronoi polygons corresponding to each point in points, clipped to the outline polygon.
get_gadm_shape(onshore_buses, gadm_shapes, geo_crs='EPSG:4326', metric_crs='EPSG:3857')
¶
Get the GADM shape for each bus by finding the nearest GADM shape to each bus.
Parameters¶
onshore_buses: pd.DataFrame DataFrame containing the onshore buses with columns ["x", "y"] gadm_shapes: gpd.GeoDataFrame GeoDataFrame containing the GADM shapes with a geometry column geo_crs : str CRS used for geographic projection, passed to GeoPandas (e.g. "EPSG:4326") metric_crs : str CRS used for distance projection, passed to GeoPandas (e.g. "EPSG:3857")
Returns¶
tuple[np.ndarray, np.ndarray] A tuple containing two arrays: - An array of geometries corresponding to the GADM shapes for each bus. - An array of indices corresponding to the GADM shape IDs for each bus.