Model Rail Networks in SUMO: Quick Beginner Guide
Read this article in clean Markdown format for LLMs and AI context.Struggling to get a train moving in SUMO? In the next few minutes you’ll learn exactly how to turn an OpenStreetMap rail segment into a working SUMO network and see a train chug along without writing a single line of XML by hand. Follow the step‑by‑step instructions below and you’ll have a functional rail line ready to experiment with.
How to Model Rail Networks in SUMO – Avoid This Mistake
When I first opened SUMO’s network editor I jumped straight into XML tutorials and complex plugins. The result? Hours of copying code that never matched my map data, and a blank screen that made me want to quit. The real issue isn’t the software—it’s trying to run before you can walk. Without a proper source file, SUMO has nothing to render, so you end up stuck in a loop of downloading, copying, and failing.
Step 1: Grab a Small Rail Segment from OpenStreetMap
- Go to OpenStreetMap.org and search for a short railway line (e.g., a stretch of 2 km).
- Click Export, choose the .osm format, and save the file as
rail.osm. - Keep the area minimal; a simple straight track is perfect for a first test.
Why this works: A tiny, clean OSM extract eliminates unnecessary data that can confuse the importer.
Step 2: Import the OSM File into SUMO’s NetEdit
- Open netedit (SUMO’s visual network editor).
- From the menu, select File → Import → OpenStreetMap.
- Browse to
rail.osmand hit Open. - NetEdit will automatically create a .net.xml network showing the rail geometry.
Pro tip: Verify that the imported edges are labeled with
type="rail"; if not, edit the edge type manually in NetEdit.
Step 3: Add Simple Signals
- Right‑click on the track where a train should stop or start.
- Choose Add → Signal and place a signal at each end of the segment.
- Accept the default settings; you’ll refine them later.
Result: Signals give SUMO a reference point for speed limits and stopping behavior, which is essential for realistic rail simulation.
Step 4: Generate a Basic Route File
Open a terminal in the folder containing rail.osm and run:
duarouter \
-n rail.net.xml \
-t rail.taz.xml \
-o rail.rou.xml \
--ignore-errors
This command creates rail.rou.xml, a minimal route definition that tells a train how to travel from the first signal to the second.
Step 5: Run the Simulation
- Launch SUMO‑gui.
- Load
rail.net.xmlas the network andrail.rou.xmlas the route file. - Press Play.
You should see a small train icon appear at the first signal and move smoothly to the second. If the travel time matches the real‑world timetable you’re modeling, congratulations—you’ve built a functional rail network.
What to Tweak Next
- Add stations by inserting additional stop points in the route file.
- Adjust signal timings in NetEdit to experiment with different headways.
- Import a larger OSM area to expand your network once you’re comfortable with the basics.
Bottom line: By breaking the process into visual steps—import → edit → signal → route—you avoid the XML overwhelm and get results instantly.
If this guide helped you get a train moving, subscribe to the Everyday Engineer newsletter for more hands‑on tutorials, and share the post with fellow simulation enthusiasts. Happy modeling!
- →