@@ -394,73 +394,71 @@ def plot_total_investment_costs(self):
394394 logging .info ('Initialisation of eGo Results' )
395395
396396
397- """
398- def geolocation_buses(network, session):
399- """
400- Use Geometries of buses x / y (lon / lat ) and Polygons
401- of Countries from RenpassGisParameterRegion
402- in order to locate the buses
403-
404- Parameters
405- - - - - - - - - - -
406- network_etrago : : class : `etrago.tools.io.NetworkScenario`
407- eTraGo network object compiled by : meth : `etrago.appl.etrago`
408- session : : sqlalchemy : `sqlalchemy.orm.session.Session < orm/session_basics.html >`
409- SQLAlchemy session to the OEDB
410-
411- """
412- # ToDo: check eTrago stack generation plots and other in order of adaptation
413- # Start db connetion
414- # get renpassG!S scenario data
415-
416- meta = MetaData()
417- meta.bind = session.bind
418- conn = meta.bind
419- # get db table
420- meta.reflect(bind=conn, schema='model_draft',
421- only=['renpass_gis_parameter_region'])
422-
423- # map to classes
424- Base = automap_base(metadata=meta)
425- Base.prepare()
426- RenpassGISRegion = Base.classes.renpass_gis_parameter_region
427-
428- # Define regions
429- region_id = ['DE', 'DK', 'FR', 'BE', 'LU',
430- 'NO', 'PL', 'CH', 'CZ', 'SE', 'NL']
431-
432- query = session.query(RenpassGISRegion.gid, RenpassGISRegion.u_region_id,
433- RenpassGISRegion.stat_level, RenpassGISRegion.geom,
434- RenpassGISRegion.geom_point)
435-
436- # get regions by query and filter
437- Regions = [(gid, u_region_id, stat_level, shape.to_shape(geom),
438- shape.to_shape(geom_point)) for gid, u_region_id, stat_level,
439- geom, geom_point in query.filter(RenpassGISRegion.u_region_id.
440- in_(region_id)).all()]
441-
442- crs = {'init': 'epsg:4326'}
443- # transform lon lat to shapely Points and create GeoDataFrame
444- points = [Point(xy) for xy in zip(network.buses.x, network.buses.y)]
445- bus = gpd.GeoDataFrame(network.buses, crs=crs, geometry=points)
446- # Transform Countries Polygons as Regions
447- region = pd.DataFrame(
448- Regions, columns=['id', 'country', 'stat_level', 'Polygon', 'Point'])
449- re = gpd.GeoDataFrame(region, crs=crs, geometry=region['Polygon'])
450- # join regions and buses by geometry which intersects
451- busC = gpd.sjoin(bus, re, how='inner', op='intersects')
452- # busC
453- # Drop non used columns
454- busC = busC.drop(['index_right', 'Point', 'id', 'Polygon',
455- 'stat_level', 'geometry'], axis=1)
456- # add busC to eTraGo.buses
457- network.buses['country_code'] = busC['country']
458-
459- # close session
460- session.close()
461-
462- return network
463- """
397+ # def geolocation_buses(network, session):
398+ # """
399+ # Use Geometries of buses x/y(lon/lat) and Polygons
400+ # of Countries from RenpassGisParameterRegion
401+ # in order to locate the buses
402+ #
403+ # Parameters
404+ # ----------
405+ # network_etrago: : class: `etrago.tools.io.NetworkScenario`
406+ # eTraGo network object compiled by: meth: `etrago.appl.etrago`
407+ # session: : sqlalchemy: `sqlalchemy.orm.session.Session < orm/session_basics.html >`
408+ # SQLAlchemy session to the OEDB
409+ #
410+ # """
411+ # # ToDo: check eTrago stack generation plots and other in order of adaptation
412+ # # Start db connetion
413+ # # get renpassG!S scenario data
414+ #
415+ # meta = MetaData()
416+ # meta.bind = session.bind
417+ # conn = meta.bind
418+ # # get db table
419+ # meta.reflect(bind=conn, schema='model_draft',
420+ # only=['renpass_gis_parameter_region'])
421+ #
422+ # # map to classes
423+ # Base = automap_base(metadata=meta)
424+ # Base.prepare()
425+ # RenpassGISRegion = Base.classes.renpass_gis_parameter_region
426+ #
427+ # # Define regions
428+ # region_id = ['DE', 'DK', 'FR', 'BE', 'LU',
429+ # 'NO', 'PL', 'CH', 'CZ', 'SE', 'NL']
430+ #
431+ # query = session.query(RenpassGISRegion.gid, RenpassGISRegion.u_region_id,
432+ # RenpassGISRegion.stat_level, RenpassGISRegion.geom,
433+ # RenpassGISRegion.geom_point)
434+ #
435+ # # get regions by query and filter
436+ # Regions = [(gid, u_region_id, stat_level, shape.to_shape(geom),
437+ # shape.to_shape(geom_point)) for gid, u_region_id, stat_level,
438+ # geom, geom_point in query.filter(RenpassGISRegion.u_region_id.
439+ # in_(region_id)).all()]
440+ #
441+ # crs = {'init': 'epsg:4326'}
442+ # # transform lon lat to shapely Points and create GeoDataFrame
443+ # points = [Point(xy) for xy in zip(network.buses.x, network.buses.y)]
444+ # bus = gpd.GeoDataFrame(network.buses, crs=crs, geometry=points)
445+ # # Transform Countries Polygons as Regions
446+ # region = pd.DataFrame(
447+ # Regions, columns=['id', 'country', 'stat_level', 'Polygon', 'Point'])
448+ # re = gpd.GeoDataFrame(region, crs=crs, geometry=region['Polygon'])
449+ # # join regions and buses by geometry which intersects
450+ # busC = gpd.sjoin(bus, re, how='inner', op='intersects')
451+ # # busC
452+ # # Drop non used columns
453+ # busC = busC.drop(['index_right', 'Point', 'id', 'Polygon',
454+ # 'stat_level', 'geometry'], axis=1)
455+ # # add busC to eTraGo.buses
456+ # network.buses['country_code'] = busC['country']
457+ #
458+ # # close session
459+ # session.close()
460+ #
461+ # return network
464462
465463
466464def results_to_excel (ego ):
0 commit comments