A Practical Guide to Creating Data‑Driven Rail Network Simulations with Free Software
Read this article in clean Markdown format for LLMs and AI context.Ever wondered how the big rail planners turn raw timetables into smooth‑running networks? The secret isn’t magic – it’s data, a bit of coding, and the right free tools. In today’s post I’ll walk you through a hands‑on workflow that anyone can follow, even if you’re just starting out. Grab a coffee, and let’s get those rails moving in the digital world.
Why go data‑driven?
At RailModel Insights we love the idea of turning numbers into insight. When you feed real ridership counts, line capacities, and delay histories into a model, the output tells you where bottlenecks hide and where a new spur could shine. A data‑driven simulation also gives you a sandbox to test “what‑if” scenarios without touching the real tracks.
Bottom line: data makes your simulation credible, and credible simulations help you make smarter decisions.
Free tools you can start with
You don’t need a pricey license to build a solid rail model. Below are three tools that are completely free and play nicely together.
SUMO (Simulation of Urban MObility)
SUMO is an open‑source traffic simulator that supports rail, tram, and metro lines. It works on Windows, macOS, and Linux, and its command‑line interface can be scripted from Python. The community provides plenty of tutorials, and you can import network files in XML format.
OpenRailwaySimulator (ORS)
ORS is a lightweight visual environment focused on railway operations. It lets you lay out tracks, place signals, and define rolling stock parameters. While it doesn’t have the heavy analytics of SUMO, it’s perfect for visual sanity checks before you dive into the numbers.
Python with Pandas, NetworkX, and Matplotlib
If you enjoy a bit of coding, the Python ecosystem gives you all the data‑wrangling and graph tools you need. Pandas reads CSVs, NetworkX builds the network graph, and Matplotlib (or Seaborn) visualizes results. All of these packages are free and well documented.
Step‑by‑step workflow
Below is a simple, repeatable process that we use at RailModel Insights for every new project. Feel free to adapt it to your own needs.
1. Gather data
Start with the basics:
- Station list – name, latitude, longitude, and passenger counts.
- Track geometry – distance between stations, line speed limits, and gradient.
- Timetables – scheduled departures and arrivals for each service.
- Historical performance – delays, cancellations, and equipment failures.
Most transit agencies publish this information in GTFS (General Transit Feed Specification) files. If you can’t find GTFS, a simple spreadsheet works just as well.
2. Build the network graph
Using Python and NetworkX, turn your station list into nodes and your track sections into edges. Each edge gets attributes like length, max speed, and capacity.
import pandas as pd, networkx as nx
stations = pd.read_csv('stations.csv')
edges = pd.read_csv('tracks.csv')
G = nx.DiGraph()
for _, row in stations.iterrows():
G.add_node(row['station_id'],
name=row['name'],
lat=row['lat'],
lon=row['lon'],
demand=row['daily_ridership'])
for _, row in edges.iterrows():
G.add_edge(row['from_id'], row['to_id'],
length=row['km'],
speed=row['max_speed'],
capacity=row['capacity'])
This creates a clean data structure that both SUMO and ORS can read.
3. Define demand
Demand is the heart of a data‑driven model. Take the daily ridership numbers from your station file and distribute them across the network using a gravity model or a simple proportional split.
def allocate_demand(G):
for u, v, data in G.edges(data=True):
# simple proportional demand based on station ridership
demand = (G.nodes[u]['demand'] + G.nodes[v]['demand']) / 2
data['demand'] = demand
allocate_demand(G)
You can get fancier later, but this baseline works for early experiments.
4. Export to SUMO
SUMO reads network files in XML. The netconvert utility can convert a CSV‑based edge list into a SUMO network. Here’s a quick command line you can run after saving edges.csv:
netconvert --csv-files edges.csv --output-file rail_net.net.xml
Then create a route file that reflects your timetable. SUMO’s duarouter will generate vehicle trips based on the demand you attached to each edge.
5. Run the simulation
With the network and route files ready, start SUMO:
sumo -c rail_simulation.sumocfg
Watch the console output or open the GUI to see trains moving along the tracks. SUMO will log travel times, delays, and queue lengths for every segment.
6. Analyse results
Pull the output files (usually output.xml or CSV) back into Python for analysis.
results = pd.read_csv('tripinfo.csv')
average_delay = results['duration'].mean() - results['routeLength'].mean() / results['speed'].mean()
print(f'Average delay per trip: {average_delay:.2f} seconds')
Plot bottleneck sections:
import matplotlib.pyplot as plt
delay_by_edge = results.groupby('edgeID')['duration'].mean()
delay_by_edge.plot(kind='bar')
plt.ylabel('Average travel time (s)')
plt.title('Where delays happen')
plt.show()
These simple visualizations often reveal the exact track segment that needs capacity upgrades or schedule tweaks.
Tips to keep things simple
- Start small. Model one line or a short corridor first. Expand once you’re comfortable with the data flow.
- Use version control. Even a single CSV change can break the network. Git (or even Dropbox) saves you from accidental loss.
- Document assumptions. Write a short README that lists data sources, demand allocation method, and any simplifications.
- Leverage community examples. SUMO’s GitHub repository has sample rail networks you can copy and modify.
- Iterate quickly. Change one parameter (like train headway) and re‑run. The faster you see the impact, the more insights you’ll gain.
Wrap up
Creating a data‑driven rail network simulation doesn’t have to be a months‑long research project. With free tools like SUMO, OpenRailwaySimulator, and the Python data stack, you can go from raw station data to actionable insights in a handful of steps. At RailModel Insights we’ve used this workflow to evaluate new commuter lines, test signal upgrades, and even forecast the ripple effects of a major service disruption. Give it a try on a small segment of your own network – you’ll be surprised how much clarity a simple simulation can bring.
Happy modelling, and remember: the best way to learn is by building. If you hit a snag, come back to this guide and retrace the steps. The rails of the digital world are waiting.
- →
- →
- →