-
Notifications
You must be signed in to change notification settings - Fork 2
Master Rail Network Tools
A set of Python scripts has been developed to perform the data handling and processing needs of maintaining the CMAP rail geodatabase. These scripts are stored as tools in the Master Rail Network Tools toolbox and are called within an ArcMap document. Here are some tips on running these scripts:
- An edit session must be closed prior to running the scripts.
- Affected feature classes must not be active in ArcCatalog when the script is running.
- All of the geodatabase feature classes (arcs, nodes and routes) must be included in the ArcMap document.
Editing Notes:
- If a new arc is digitized, the following fields in the arc table must be manually updated: MILES, MODES1, MODES2, and DIRECTIONS.
- ANODE and BNODE in the arc table should never be manually edited; the scripts will update these values automatically.
- If a link is split, MODES1, MODES2 and DIRECTIONS for the affected links may be manually updated if necessary. The MILES should not be manually edited for these links, as the script will recalculate the values.
- No more than two new nodes should be added to a specific link, by splitting it, within a round of processing. If more are required: two nodes should be added, the network should be processed, and then more can be added (still limited to two new nodes per link). This is a constraint caused by the SAS processing program and may be revisited if it causes a problem.
- If a new node is added, all fields in the node table must be manually updated.
- To delete a node, delete one of the arcs attached to it and connect the other arc to the next node that is not being deleted. Manually update either ANODE or BNODE for the arc that was just extended by replacing the NODE value of the node that will be deleted with the NODE value of the node to which it was extended. This is the only time that a manual update of ANODE or BNODE attributes is required. MILES should also be manually updated to reflect the extension of the arc. Lastly, any general future itinerary coding (those with one or more "*" in TR_LINE) that is affected should be manually updated before running the tool. Only one node at a time can be deleted, so run the tool after each set of edits to delete the node and update itineraries.
Run the Update Network Edits tool (used for edits including deleting arcs, digitizing new arcs, splitting existing links, moving the ends of arcs, adding/deleting arc shape points, or deleting routes from the route table).
- This calls update_network_edits.py to update the node feature class to reflect any changes made to the arcs and updates the node coordinates. Data are processed as follows:
- The coordinates for all arc ends are obtained.
- This script calls the SAS program update_nodes.sas (via sasrun.bat) to process the arc end coordinates and to identify nodes that should be added or removed from the node feature class. If links were split, a file of those links is created.
- The node feature class is rebuilt with the updated topology.
- If links were split, the file created by the SAS program is used to update MILES in the arc feature class for the affected links. Additionally, temporary values for ANODE or BNODE (starting with the value "90001") will be assigned to the affected links in the arc table where the new nodes are represented. These values are used to ensure each arc has a unique ANODE–BNODE combination.
- The geometry for all arcs is written to a file so the routes can be rebuilt.
- The SAS program geometry_update.sas is called to create new input geometry files for the routes by combining the itinerary coding with the new arc geometry file. This ensures the routes are coincident with the underlying arcs. The route geometry file includes an m-value for each route vertex, which allows the itinerary table to be plotted as linear route events. The program also identifies routes deleted from the route feature classes and removes their itinerary coding.
- If links were split and itinerary coding is affected, the SAS program itinerary_node_update.sas will alter the coding to insert all of the “splits” into the position held by the original link (using the temporary ANODE/_BNODE_values) and will recalculate the itinerary attributes as needed. These ANODE/BNODE values are temporary in that they will be replaced with the true node value once it is entered into the node table and the appropriate script is submitted.
- The Python script updates the route feature classes and their itinerary tables in the geodatabase.
Edits to feature class field values (with the exception of NODE in the node feature class and MILES in the arc feature class) do not require any additional processing.
Run the Update Anode Bnode Values tool (used when new nodes are added to the network or when new node numbers are assigned in the node feature class).
- First, manually update the NODE for the new nodes in the node feature class (CTA rail stations use the node range 30000-38999 and CTA rail junctions use 39000-39999; Metra stations use 40000-48999 and Metra junctions use 49000-49999).
- Running the tool will call update_anode_bnode_values.py to revise ANODE and BNODE in the arc feature class with the NODE values in the node feature class.
- If links were previously split, the SAS program update_split_itinerary.sas is called (via sasrun.bat) to update the node values in the itinerary coding for routes affected by split links with the newly-assigned node numbers.
Run the Import Rail Coding tool.

The arguments required are the data input files. Either
- Future Rail Coding Spreadsheet: Navigate to the spreadsheet containing coding for future rail service. or
- Transit Feed Input Route File: Navigate to the comma-delimited file containing GTFS route header information.
- Transit Feed Input Itinerary File: Navigate to the comma-delimited file containing GTFS route itinerary coding (submitted as a pair). (Note: Feature Class to be Updated is automatically selected by the tool.)
- This calls import_rail_coding.py to import the rail route coding into the appropriate route feature class and updates the corresponding itinerary coding.
- This script calls the SAS program geometry_update.sas (via sasrun.bat) to process all of the data. It performs the same functions that are listed under update_network_edits.py, but calls some additional scripts:
- read_rail_coding_spreadsheet.sas is called to process and format the spreadsheet coding (future project coding).
-
read_rail_feed_data.sas is called to process and format the .csv file data (GTFS data).
- If the itinerary coding contains gaps (i.e., it does not provide a continuous stream of stops that exactly match network links), write_dictionary.sas is called to write a file of connected network links and their lengths for some shortest path analysis. The file is written as a Python dictionary.
- find_shortest_path.py is then called to find the shortest path using available network links to fill in the itinerary gaps.
- read_path_output.sas is then called to insert the shortest path data into the itineraries and recalculate all appropriate variables.
- The Python script then completes the task of importing new/revised coding into the geodatabase.
Run the Generate Rail Files tool.

Required arguments:
- The path of the source MRN geodatabase.
- The scenario numbers of networks to generate (available from a checklist of all allowable values).
- The path of the destination root folder for the output files.
- This calls generate_rail_files.py to perform the processing.
- This script calls the SAS program generate_rail_files.sas (via sasrun.bat) to process all of the existing rail routes and write the Emme transaction files.
- For future scenarios, an additional program (apply_future_rail_actions.sas) is called to process the future rail coding.
- While each commuter rail run is retained in the Emme network, CTA rail service is included as generalized service so collapse_CTA_runs.sas is called to analyze the individual CTA runs and combine similar service. The Python script gfts_collapse_routes.py performs the actual similarity testing.