mv_grid_districts
The module containing all code to generate MV grid district polygons.
Medium-voltage grid districts describe the area supplied by one MV grid and are defined by one polygon that represents the supply area.
- class HvmvSubstPerMunicipality(**kwargs)[source]
Bases:
BaseClass definition of temporary table grid.hvmv_subst_per_municipality.
- ags_0
- area_ha
- bem
- bez
- count_hole
- gen
- geometry
- id
- is_hole
- nuts
- old_id
- path
- rs_0
- subst_count
- class MvGridDistricts(**kwargs)[source]
Bases:
BaseClass definition of table grid.egon_mv_grid_district.
- area
- bus_id
- geom
- class MvGridDistrictsDissolved(**kwargs)[source]
Bases:
BaseClass definition of temporary table grid.egon_mv_grid_district_dissolved.
- area
- bus_id
- geom
- id
- class Vg250GemClean(**kwargs)[source]
Bases:
BaseClass definition of table boundaries.vg250_gem_clean.
- ags_0
- area_ha
- bem
- bez
- count_hole
- gen
- geometry
- id
- is_hole
- nuts
- old_id
- path
- rs_0
- class VoronoiMunicipalityCuts(**kwargs)[source]
Bases:
VoronoiMunicipalityCutsBase,BaseClass definition of temporary table grid.voronoi_municipality_cuts.
- ags_0
- bus_id
- geom
- geom_sub
- id
- municipality_id
- subst_count
- voronoi_id
- class VoronoiMunicipalityCutsAssigned(**kwargs)[source]
Bases:
VoronoiMunicipalityCutsBase,BaseClass definition of temporary table grid.voronoi_municipality_cuts_assigned.
- ags_0
- bus_id
- geom
- geom_sub
- id
- municipality_id
- subst_count
- temp_id
- voronoi_id
- class VoronoiMunicipalityCutsBase[source]
Bases:
object- ags_0 = Column(None, String(), table=None)
- bus_id = Column(None, Integer(), table=None)
- geom = Column(None, Geometry(geometry_type='POLYGON', srid=3035), table=None)
- geom_sub = Column(None, Geometry(geometry_type='POINT', srid=3035), table=None)
- municipality_id = Column(None, Integer(), table=None)
- subst_count = Column(None, Integer(), table=None)
- voronoi_id = Column(None, Integer(), table=None)
- assign_substation_municipality_fragments(with_substation, without_substation, strategy, session)[source]
Assign bus_id from next neighboring polygon to municipality fragment
For parts municipalities without a substation inside their polygon the next municipality polygon part is found and assigned.
Resulting data including information about the assigned substation is saved to
VoronoiMunicipalityCutsAssigned.- Parameters:
with_substation (SQLAlchemy subquery) – Polygons that have a substation inside or are assigned to a substation
without_substation (SQLAlchemy subquery) – Subquery that includes polygons without a substation
strategy (str) – Either
“touches”: Only polygons that touch another polygon from with_substation are considered
“within”: Only polygons within a radius of 100 km of polygons without substation are considered for assignment
session (SQLAlchemy session) – SQLAlchemy session object
Notes
The function
nearest_polygon_with_substation()is very similar, but different in detail.
- define_mv_grid_districts()[source]
Define spatial extent of MV grid districts.
The process of identifying the boundary of medium-voltage grid districts is organized in three steps:
substations_in_municipalities(): The number of substations located inside each municipality is calculated.split_multi_substation_municipalities(): The municipalities with >1 substation inside are split by Voronoi polygons around substations.merge_polygons_to_grid_district(): All polygons are merged such that one polygon has exactly one single substation inside.
Finally, intermediate tables used for storing data temporarily are deleted.
- merge_polygons_to_grid_district()[source]
Merge municipality polygon (parts) to MV grid districts.
Polygons of municipalities and cut parts of such polygons are merged to a single grid district per one HV-MV substation. Prior determined assignment of cut polygons parts is used as well as proximity of entire municipality polygons to polygons with a substation inside.
Step 1: Merge municipality parts that are assigned to the same substation.
Step 2: Insert municipality polygons with exactly one substation.
Step 3: Assign municipality polygons without a substation and insert to table.
Step 4: Merge MV grid district parts.
Data is written to table grid.egon_mv_grid_district and to temporary table grid.egon_mv_grid_district_dissolved.
- class mv_grid_districts_setup(dependencies)[source]
Bases:
DatasetSets up medium-voltage grid districts that describe the area supplied by one MV grid.
See documentation section MV grid districts for more information.
- Dependencies
- Resulting tables
grid.egon_mv_grid_districtis created and filledboundaries.vg250_gem_cleanis created and filled
- name: str = 'MvGridDistricts'
- sources: DatasetSources = DatasetSources(tables={'vg250_gem_clean': 'boundaries.vg250_gem_clean', 'hvmv_substation': 'grid.egon_hvmv_substation', 'hvmv_substation_voronoi': 'grid.egon_hvmv_substation_voronoi'}, files={}, urls={})
The sources used by the datasets. Could be tables, files and urls
- targets: DatasetTargets = DatasetTargets(tables={'egon_mv_grid_district': 'grid.egon_mv_grid_district'}, files={})
The targets created by the datasets. Could be tables and files
- version: str = '0.0.5'
- nearest_polygon_with_substation(with_substation, without_substation, strategy, session)[source]
Assign next neighboring polygon.
For municipalities without a substation inside their polygon the next MV grid district (part) polygon is found and assigned.
Resulting data including information about the assigned substation is saved to
MvGridDistrictsDissolved.- Parameters:
with_substation (SQLAlchemy subquery) – Polygons that have a substation inside or are assigned to a substation
without_substation (SQLAlchemy subquery) – Subquery that includes polygons without a substation
strategy (str) – Either
“touches”: Only polygons that touch another polygon from with_substation are considered
“within”: Only polygons within a radius of 100 km of polygons without substation are considered for assignment
session (SQLAlchemy session) – SQLAlchemy session object
- Returns:
list – IDs of polygons that were already assigned to a polygon with a substation.
- split_multi_substation_municipalities()[source]
Split municipalities that have more than one substation.
Municipalities that contain more than one HV-MV substation in their polygon are cut by HV-MV voronoi polygons. Resulting fragments are then assigned to the next neighboring polygon that has a substation.
In detail, the following steps are performed:
Step 1: Cut municipalities with voronoi polygons.
Step 2: Determine number of substations inside cut polygons.
Step 3: Separate cut polygons with exactly one substation inside.
Step 4: Assign polygon without a substation to next neighboring polygon with a substation.
Step 5: Assign remaining polygons that are non-touching.
Data is written to temporary tables grid.voronoi_municipality_cuts and grid.voronoi_municipality_cuts_assigned.
- substations_in_municipalities()[source]
Create a table that counts number of HV-MV substations in each MV grid.
Counting is performed in two steps:
HV-MV substations are spatially joined on municipalities, grouped by municipality and number of substations counted.
Because (1) works only for number of substations >0, all municipalities not containing a substation, are added.
Data is written to temporary table grid.hvmv_subst_per_municipality.