uxsim.OSMImporter2.OSMImporter2¶
OpenStreetMap importer using OSMnx and neatnet. Work in progress. Import from OSM is experimental and may not work as expected. It is functional but may produce inappropriate networks for simulation, such as too many nodes, too many deadends, fragmented networks.
Confirmed version: neatnet 0.1.0
Functions
|
Imports OpenStreetMap (OSM) network data into a World object. |
- uxsim.OSMImporter2.OSMImporter2.osm_network_to_World(W, north=None, south=None, east=None, west=None, bbox=None, custom_filter='["highway"~"trunk|primary"]', simplification=True, override_osm_attributes=False, set_node_capacity=True, maxspeed_by_road_type={}, lanes_by_road_type={}, kwargs_dict_for_osmnx_graph_from_bbox={}, kwargs_dict_for_osmnx_project_graph={}, kwargs_dict_for_neatnet_neatify={})[source]¶
Imports OpenStreetMap (OSM) network data into a World object. This function retrieves OSM road network data within the specified bounding box, simplifies the network, and extracts nodes and links using OSMnx and neatnet. Then it attaches them to the World object.
- Parameters:
W (World) – The World object to which the OSM network will be added.
north (float, optional) – The latitudes and longitudes defining the boundaries of the area to be imported.
south (float, optional) – The latitudes and longitudes defining the boundaries of the area to be imported.
east (float, optional) – The latitudes and longitudes defining the boundaries of the area to be imported.
west (float, optional) – The latitudes and longitudes defining the boundaries of the area to be imported.
bbox (list, optional) – The bounding box of the area to be imported. Format is [west, south, east, north]. This parameter takes precedence over individual north, south, east, west arguments.
custom_filter (str, default='["highway"~"trunk|primary"]') –
The OSM filter to be used for importing the data. Examples:
’[“highway”~”motorway”]’: highways only
’[“highway”~”motorway|trunk|primary|secondary|tertiary”]’: highways and major/mid arterials
simplification (bool, default=True) – If True, the network is simplified using neatnet’s neatify function. If False, the original network is used.
override_osm_attributes (bool, default=False) – If True, the function will override OSM attributes (maxspeed, lanes) with default values. This can be useful when OSM data is erroneous or inconsistent. If False, it will use the attributes from the OSM data.
set_node_capacity (bool, default=True) – If True, automatically determines flow capacity of nodes based on connected links. If False, the capacity is unbounded. This simulates traffic signals in a continuous manner.
maxspeed_by_road_type (dict, default={}) – Dictionary to override default speed limits for different road types.
lanes_by_road_type (dict, default={}) – Dictionary to override default number of lanes for different road types.
kwargs_dict_for_osmnx_graph_from_bbox (dict, default={}) – Additional keyword arguments to pass to OSMnx’s graph.graph_from_bbox function.
kwargs_dict_for_osmnx_project_graph (dict, default={}) – Additional keyword arguments to pass to OSMnx’s project_graph function.
kwargs_dict_for_neatnet_neatify (dict, default={}) – Additional keyword arguments to pass to neatnet’s neatify function.
- Returns:
The function modifies the World object in-place by adding OSM nodes and links.
- Return type:
None
Notes
The function performs three main steps:
Obtains and simplifies the OSM network using OSMnx and neatnet
Extracts node and link information from the simplified network
Attaches the extracted nodes and links to the World object