Real-world railway networks for reinforcement learning environments

A web-based application that imports railway infrastructure from OpenStreetMap, simplifies it and converts it into grid-based Flatland environments for railway scheduling and reinforcement learning experiments.

Header image

Initial situation

Flatland provides a lightweight, two-dimensional railway simulation environment that is well suited to fast experimentation with scheduling approaches such as reinforcement learning. However, real railway networks cannot be imported automatically. Users must either work with randomly generated networks or recreate infrastructure manually, tile by tile. At the same time, OpenStreetMap contains detailed railway infrastructure, but its data is often more detailed than timetable simulations require and its metadata can be incomplete or inconsistent.

Problem statement / Project goal

The project aimed to bridge this gap by developing a web application that imports a real-life railway network from OpenStreetMap and converts it into a Flatland environment. Two aspects were central: implementing a data pipeline that transforms railway data into a graph and grid representation usable by Flatland, and designing an expert-user interface that lets users select an area and efficiently exclude sidings and other infrastructure that is not relevant to the intended timetable simulation.

Conversion pipeline

FHNW

The data pipeline collects the data and enriches it with more data from both OpenStreetMap and user input. Then over multiple steps the data is transformed into first a grid and then into a Flatland environment

Station example

FHNW

Example of station mapped by the algorithm

Complete line

FHNW

Complete export of the Railway line Luzern Verkehrshaus - Immensee

Solution developed and its benefits

The project produced a web application with a Python backend and an Angular frontend. Railway infrastructure is fetched through OSMnx and the Overpass API, enriched with station information and simplified. Each station is rotated and mapped onto a grid using a multistage placement process. The individual station grids are then positioned in a common layout, connected and converted into Flatland transition cells. The resulting RailEnvironment can be rendered for validation and serialized for use in simulations.

  • automatically imports real railway infrastructure from OpenStreetMap instead of requiring manual tile-by-tile construction
  • supports precise geographic selection of the network to be converted
  • provides a multi-level filtering concept for global, station and track-specific simplification
  • maps small to medium-sized stations into recognizable Flatland grid layouts
  • combines multiple mapped stations into a complete railway-line representation
  • exports a valid Flatland environment ready for simulation
  • provides a rendered snapshot for quick validation of the generated environment

The implementation demonstrates that the basic concept is viable and can substantially reduce the effort required to represent a real railway network in Flatland. The station-based mapping approach works particularly well where platforms and stop points provide strong straight paths that can serve as anchors for the layout.

The current solution remains a proof of concept. It can handle small to medium-sized stations and railway lines without switches between stations, but larger stations with many sidings, crossovers or other complex structures can still lead to unsuitable placements. The web frontend is also only partially implemented. The thesis identifies switch detection, divergent-node placement, nodes between stations, GUI completion and systematic testing as the main areas for future work.

Key terms

  • Flatlandrailway simulation environment
  • OpenStreetMapreal-world railway infrastructure data
  • OSMnx / Overpass APIdata acquisition and graph representation
  • Railway network conversiongraph-to-grid transformation
  • Reinforcement learningtrain scheduling experiments
  • Python / Angularbackend pipeline and web frontend

Customer

FLATLAND Association
Manuel Schneider

Team

Noah Schaub

Advisors
Anton Fedosov Raphael Lüthy