GraphGenerator
todo
- class blocksnet.preprocessing.graph_generator.GraphNode(*, x: float, y: float)[source]
Bases:
BaseModel- x: float
- y: float
- class blocksnet.preprocessing.graph_generator.GraphEdge(*, geometry: LineString = None, weight: float, transport_type: Literal['walk', 'drive', 'subway', 'tram', 'bus', 'trolleybus'])[source]
Bases:
BaseModel- geometry: LineString
- weight: float
- transport_type: Literal['walk', 'drive', 'subway', 'tram', 'bus', 'trolleybus']
- class blocksnet.preprocessing.graph_generator.CityRow(*, geometry: Polygon | MultiPolygon, index: int)[source]
Bases:
BaseRow- geometry: Polygon | MultiPolygon
- class blocksnet.preprocessing.graph_generator.GraphGenerator(*, territory: GeoDataFrame[CityRow], overpass_url: str = 'http://lz4.overpass-api.de/api/interpreter', speed: dict[str, int] = {'bus': 17, 'drive': 25, 'subway': 12, 'tram': 15, 'trolleybus': 12, 'walk': 4}, waiting_time: dict[str, int] = {'bus': 5, 'subway': 5, 'tram': 5, 'trolleybus': 5})[source]
Bases:
BaseModel- territory: GeoDataFrame[CityRow]
City geometry or geometries, may contain blocks or boundaries of the city
- overpass_url: str
Overpass url used in OSM queries
- speed: dict[str, int]
Average transport type speed in km/h
- waiting_time: dict[str, int]
Average waiting time in min
- property local_crs
- _get_basic_graph(network_type: Literal['walk', 'drive'])[source]
Returns walk or drive graph for the city geometry
- _get_routes(bounds: DataFrame, public_transport_type: Literal['subway', 'tram', 'trolleybus', 'bus']) DataFrame[source]
Returns OSM routes for the given geometry shapely geometry bounds and given transport type
- static _coordinates_to_linestring(coordinates: list[dict[str, float]]) LineString[source]
For given route coordinates dicts returns a concated linestring
- _ways_to_gdf(df: DataFrame) GeoDataFrame[source]
Returns GeoDataFrame for the given route ways, converting way’s coordinates to linestring
- _nodes_to_gdf(df: DataFrame) GeoDataFrame[source]
Returns GeoDataFrame for the given route nodes, converting lon and lat columns to geometry column and local CRS
- _graph_from_route(nodes: DataFrame, ways: DataFrame, transport_type: str) list[networkx.classes.multigraph.MultiGraph][source]
Get graph for the given route nodes and ways
- _get_pt_graph(pt_type: Literal['subway', 'tram', 'trolleybus', 'bus']) list[networkx.classes.multigraph.MultiGraph][source]
Get public transport routes graphs for the given transport_type