Irish Rail has an API that affords the ability to retrieve the real time location of their trains. In this project I used the python requests package to retrieve real time train locations from this API. The response was in XML format with an array of trains with each train having a code, status, direction along with their latitude and longitude. I parsed the XML for each train and created a Pandas DataFrame containing this information. Once I had figured how to do this at one point-in-time I then ran a task scheduler to do it repeatedly at a set frequency (every two minutes) over a chosen time window (60 minutes) on the 19th October 2023.
For each of these moments in time I represented the trains on a Folium map with added GeoJSON layers for the rail network and rail stations which I had downloaded from the Ordnance Survey Ireland website (see below (the trains are clickable)). ( Need to figure out an iframe issue to display in page but standalone page here )
In order to display the dynamics of the trains I ran a webdriver (using Selenium) to open each of the (html) Folium maps and take a png screenshot. I then combined the pngs into a gif - see below. Unfortunately, it appears that you don't really get the real time location from the API as the trains seem to make discrete jumps between stations as time evolves.
I can also do the same thing looking at the Dublin region only (see below).
If you are interested in seeing how this was done the code for this project is available on my GitHub here