"real-time" train traffic in the Netherlands
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
LICENSE
README.md
collect_data.sh
example.png
main.py
make_trains.sh
raw_data.tgz
stations.xml
stations_codes_all.txt
stations_codes_foreign.txt
stations_codes_nl.txt
train_numbers.txt
trains.json

README.md

"Real-time" train traffic in the Netherlands

For fun I've created a few scripts to reconstruct "real-time" train traffic in the Netherlands using NS public API.

what's wrong with the picture?

For video and more information see

Remaking a video

Just run main.py (it takes a long time and memory usage builds up). It requires a few things:

  • python3
  • python3-matplotlib
  • python3-xmltodict
  • python3-mpltoolkits.basemap

It loads data from trains.json and stations.xml. Running this script produces lots of png files. ffmpeg can be used to make a video out of them:

ffmpeg -framerate 10 -pattern_type glob -i '*.png' -c:v libx264 -pix_fmt yuv420p trains.mp4

Collecting raw data from NS

collect_data.sh script saves current departure information for all stations in the Netherlands. After that make_trains.sh reconstructs train routes and replaces trains.json. To remake pngs run main.py