Public transport
Public transport supply is prepared with PT2MATSim, an open-source Java package developed within the MATSim ecosystem for preparing multimodal transport-supply data for MATSim simulations (Poletti, 2017).
| Repository | github.com/matsim-org/pt2matsim |
| Language | Java |
| Purpose | Convert public transit data and OSM data into fully mapped MATSim network, schedule and vehicle XML files |
What it converts
The package converts public transport timetable data into MATSim-compatible transit schedules, from three input formats:
| Format | Full name | Support |
|---|---|---|
| GTFS | General Transit Feed Specification | Full |
| HAFAS | HaCon Fahrplan-Auskunfts-System | Full |
| OSM | OpenStreetMap | With limitations |
It also provides tools for generating multimodal transport networks from OSM data.
The Public Transit Mapper
A key function of PT2MATSim is to map public transport services onto the physical transport network, and this is the part worth understanding properly.
The problem it solves
Public transport feeds initially describe stops, routes and service times. What they do not necessarily identify is the sequence of MATSim network links each service actually uses.
A timetable says a bus leaves stop A at 08:04 and reaches stop B at 08:11. It does not say which roads it took to get there, and the simulation needs that to model the bus interacting with traffic.
PT2MATSim's Public Transit Mapper resolves this in two steps:
- Identifying candidate network links for transit stops
- Calculating suitable paths between them
The result is a fully mapped public transport schedule that can be used for agent-based transport simulation in MATSim.
Inputs
There are two principal inputs: a geospatial representation of the transport infrastructure, and public transport timetable data.
1. The physical network
The physical network can be constructed from OpenStreetMap data. In practice this
means selecting a sub-region and downloading it in *.osm.pbf format, for example
from Geofabrik, then converting it into a
multimodal MATSim network containing roads and other infrastructure used by the
relevant transport modes.
2. Public transport timetable data
Public transport information must contain:
- Stops
- Routes
- Trips
- Service calendars
- Arrival and departure times
This can be supplied directly in GTFS format.
The Great Britain complication
For applications in Great Britain, source timetable data may require preprocessing, because national datasets are often distributed in UK-specific formats rather than GTFS.
| Mode | Provider | Native format |
|---|---|---|
| Rail | Rail Delivery Group | Common Interface Format (CIF) |
| Bus and other local public transport | Various | Formats such as TransXChange |
UK2GTFS
The University of Leeds' UK2GTFS R package bridges the gap (University of Leeds, 2022). It can:
- Convert TransXChange and ATOC/CIF timetable data into GTFS
- Clean and validate the resulting feeds
- Merge multiple GTFS datasets into a common dataset
The merged output is then supplied to PT2MATSim.
Why merging is a required step, not an optional one
Rail and bus data arrive from different providers in different formats. Both sets of text files need to be merged into one single set of files before PT2MATSim can use them, because MATSim expects a single coherent schedule rather than several overlapping feeds.
Where to obtain the data
| Source | Covers |
|---|---|
| Rail Delivery Group | Rail information |
| Traveline | The rest of public transport services, such as bus, metro and ferry |
Regional transport operators or authorities may also provide additional GTFS or timetable datasets that can be incorporated where required. The handbook gives East Yorkshire Buses as an example of a regional body that might supply this information.
Outputs
| File | Contents |
|---|---|
network.xml | Each node and road link in the study area, with road length, maximum speed, allowed modes, flow capacity, number of lanes and similar attributes |
transitschedule.xml | All public transport services in the study area, including routes, schedules and stops. Routes are linked to network.xml |
transitVehicles.xml | The characteristics of each public transport vehicle, such as bus, rail or metro |
These are described in full on the MATSim network page.
Internal reference in the source
The handbook notes that example output files can be found in an internal
Section_6_TransportSupply Teams folder. That location is not publicly accessible
and should be replaced with a citable source, or removed, before publication.

