Create Network Scenario - Bi-County-AlaCC-Activity-Based-Model/client_actc_ccta_model_doc GitHub Wiki
Home > TravelModel > UsersGuide > NetworkCoding > Create Network Scenario
The Bi-county model network scenarios are managed using Network Wrangler, a Python library that allows for the management of travel model network scenarios. It can operate on networks that are stored in the 'standard network' format, create scenarios, and apply changes to the scenario network using project cards. Lasso, another Python library that works as a wrapper around Network Wrangler, handles model-specific settings and functionalities.
Standard network is a general network format that is software agnostic and can be converted into multiple proprietary mainstream transportation modeling software formats.
Standard roadway network consists of 3 files that together describe roadway information: links.json
, shapes.geojson
, and nodes.geojson
.
Standard transit network is stored in a 'GTFS-like' format, which follows the general format and file structures of the GTFS, but with extra attributes that link transit to the underlying model roadway network, such as model_node_id
.
Starting from a pre-processed base standard network, the major steps to create network scenario are as follows:
- Read in the standard network.
roadway_net = RoadwayNetwork.read( link_filename = 'standard_links.json', node_filename = 'standard_nodes.geojson', shape_filename = 'standard_shapes.geojson' ) transit_net = TransitNetwork.read(feed_path = <standard_network_dir>))
- Attribute the network with attributes required by the model, such as the number of lanes, facility type, and use class.
- Create base network scenario using the attributed standard network
base_scenario = Scenario.create_scenario( base_scenario = {"road_net": roadway_net, "transit_net": transit_net} )
- Create an updated scenario and apply project cards. Note that this can be performed sequentially, meaning creating a scenario on top of another scenario and adding extra network changes.
update_scenario = Scenario.create_scenario( base_scenario= base_scenario, card_directory = extra_project_card_dir, project_cards_list = [], validate_project_cards=False ) update_scenario.apply_all_projects()
- (Optional) Write out scenario pickle file for future use.
scenario_filename = os.path.join(data_dir, f'scenario_{scenario_year}.pickle') pickle.dump(update_scenario, open(scenario_filename, 'wb'))
- Write out scenario network to Cube-compatible format
- Roadway
- Convert standard roadway network to model roadway network. This step handles creating geometries and attributes for parallel managed lanes, as well as time-period-specific network attributes.
model_net = ModelRoadwayNetwork.from_RoadwayNetwork( roadway_network_object = update_scenario.road_net, parameters = parameters ) mtc_model_net = mtc.roadway_standard_to_mtc_network(model_net, parameters)
- Write out to Cube
.net
file.model_net.write_roadway_as_fixedwidth( output_dir = os.path.join(data_dir, 'model_networks', f"{scenario_year}", 'hwy'), output_link_txt = 'links.txt', output_node_txt = 'nodes.txt', output_link_header_width_txt = 'links_header_width.txt', output_node_header_width_txt = 'nodes_header_width.txt', output_cube_network_script = 'make_complete_network_from_fixed_width_file.s', )
- Convert standard roadway network to model roadway network. This step handles creating geometries and attributes for parallel managed lanes, as well as time-period-specific network attributes.
- Transit
standard_transit_net = StandardTransit.fromTransitNetwork(update_scenario.transit_net, parameters = parameters) mtc.write_as_cube_lin(standard_transit_net, parameters, outpath = os.path.join(data_dir, 'model_networks', 'trn', f"{scenario_year}/transit.lin"))
- Roadway