• Our new ticketing site is now live! Using either this or the original site (both powered by TrainSplit) helps support the running of the forum with every ticket purchase! Find out more and ask any questions/give us feedback in this thread!

New Train Plotting Tool

johnsmith147

Member
Joined
20 Mar 2024
Messages
19
Location
Durham
Hello all,

I thought I'd share a little project I've been working on over the last week or two -- a nice way to visualise live (or not live!) train positions along a given route. It uses RTT data and then does some reasonably fancy maths to predict current locations down to the second/make everything pretty.

Attached is a plot of Newcastle to York from earlier today -- you can plot much longer routes and they look very nice but alas railforums doesn't like big pictures! Any route which has a direct train along it it can be used, though if it's really long it becomes very slow to collect all the data. Other than just knowing what's about to go past, I find it's very useful to identify how the effects of disruption ripple around.

Link here: https://trainplots.streamlit.app/

Let me know what you think, or anything reasonably simple you'd like adding.

Thanks, and enjoy fiddling,
Oliver
 

Attachments

  • NCL_YRK.png
    NCL_YRK.png
    635.2 KB · Views: 459
Sponsor Post - registered members do not see these adverts; click here to register, or click here to log in
R

RailUK Forums

The Planner

Veteran Member
Joined
15 Apr 2008
Messages
17,902
Effectively a train planning graph with a "live" element. Surprised no one has managed it before with open data.
 

Welshguy1048

Member
Joined
6 Apr 2023
Messages
1,092
Location
Prestatyn
@johnsmith147

Morning

I am getting this message when i click on your link...

Screenshot of message
 

Attachments

  • Screenshot_20250319_091000_com.android.chrome.jpg
    Screenshot_20250319_091000_com.android.chrome.jpg
    358.2 KB · Views: 173

johnsmith147

Member
Joined
20 Mar 2024
Messages
19
Location
Durham
Effectively a train planning graph with a "live" element. Surprised no one has managed it before with open data.
Indeed. Getting basic plots joining up the raw data wasn't very difficult at all, but making it neat and usable took some time...

== Doublepost prevention - post automatically merged: ==

@johnsmith147

Morning

I am getting this message when i click on your link...

Screenshot of message
Thanks for having a look - I'm quite severely restricted by not wanting to pay for a server... Hopefully once this post isn't new it won't be a problem, but I'll just keep resetting it for now. Should be working again.
 

Welshguy1048

Member
Joined
6 Apr 2023
Messages
1,092
Location
Prestatyn
Indeed. Getting basic plots joining up the raw data wasn't very difficult at all, but making it neat and usable took some time...

== Doublepost prevention - post automatically merged: ==


Thanks for having a look - I'm quite severely restricted by not wanting to pay for a server... Hopefully once this post isn't new it won't be a problem, but I'll just keep resetting it for now. Should be working again.
@johnsmith147

Okay

No worries

Dave
 

sharpener

Member
Joined
4 Oct 2018
Messages
119
Hello all,

I thought I'd share a little project I've been working on over the last week or two -- a nice way to visualise live (or not live!) train positions along a given route. It uses RTT data and then does some reasonably fancy maths to predict current locations down to the second/make everything pretty.

Attached is a plot of Newcastle to York from earlier today -- you can plot much longer routes and they look very nice but alas railforums doesn't like big pictures! Any route which has a direct train along it it can be used, though if it's really long it becomes very slow to collect all the data. Other than just knowing what's about to go past, I find it's very useful to identify how the effects of disruption ripple around.

Link here: https://trainplots.streamlit.app/

Let me know what you think, or anything reasonably simple you'd like adding.

Thanks, and enjoy fiddling,
Oliver

Brilliant, well done. Just what I said we needed over in this thread but the ppl there said it couldn't be done with today's technology(!)
 

The Planner

Veteran Member
Joined
15 Apr 2008
Messages
17,902
Brilliant, well done. Just what I said we needed over in this thread but the ppl there said it couldn't be done with today's technology(!)
But this doesnt provide that either? Its an open source version of a live graph that some locations already have? You can't manipulate the data to see the outcome of a potential decision?
 

Horizon22

Established Member
Associate Staff
Jobs & Careers
Joined
8 Sep 2019
Messages
9,560
Location
London
But this doesnt provide that either? Its an open source version of a live graph that some locations already have? You can't manipulate the data to see the outcome of a potential decision?

Exactly. Some software will map this - I believe Luminate may - and throw up warnings but it's still quite intensive to check through everything. Especially during disruption where lots of other tasks are required.
 
Joined
24 Jul 2011
Messages
505
Location
Wigan
This looks fantastic! You've done a superb job at making it readable and the backend required to do this is impressive. Keep up the good work!
 

JKF

Member
Joined
29 May 2019
Messages
1,028
I guess it’s a nice way of seeing when your train might pass others.

I’ve sometimes wanted for a similar feature on RTT, where you enter your train and as well as timing points it also lists where you pass others trains. Though I guess that would get messy very quickly if for instance you were passing through Clapham Jn or Stratford!
 

Omnishambles

Member
Joined
13 Jul 2019
Messages
142
Thank you! I had assumed the industry uses this kind of thing all the time to make signalling decisions, but perhaps not...
First saw this 15 years ago from a number of different suppliers with only Luminate now having similar version in place and not nationwide. Good luck evolving this and look forward to seeing a permanently open thread in the future with member’s views as to what they would have done by using it, should bring some (ahem!) lively discussion
 

johnsmith147

Member
Joined
20 Mar 2024
Messages
19
Location
Durham
I really like this! is there anyway of getting the train Headcodes to show on the plot?
I've now added headcodes (rudimentarily) -- can be a bit of a mess around busy stations but I can't see an easy way around that. Also fixed a bug with trains not appearing if they start running during live plotting.

== Doublepost prevention - post automatically merged: ==

I guess it’s a nice way of seeing when your train might pass others.

I’ve sometimes wanted for a similar feature on RTT, where you enter your train and as well as timing points it also lists where you pass others trains. Though I guess that would get messy very quickly if for instance you were passing through Clapham Jn or Stratford!
I could probably write something like this without too much new code, but it would likely be quite difficult to predict where things pass exactly without knowing all the linespeeds and things. If there is keenness from others then I'll give it a go
 

pokemonsuper9

Established Member
Joined
20 Dec 2022
Messages
2,832
Location
Greater Manchester
I get why they are like this but the distance values would probably be better displayed as the multiples of 1/80 miles they are rather than floating point inaccuracies.
Screenshot of the mileage distances on the Atherton line, many values are very long (e.g. 1.70000000000000002) due to floating point inaccuracy.
 

PyrahnaRanger

Member
Joined
16 Aug 2022
Messages
266
Location
Lancashire
So I tried this on the Cumbrian coast line - just to get a feel for what it does. In one sense, it's quite a boring graph as there's only really one train at a time going up and down, but the passing place looks about right from memory.

What's also interesting is that it shows the service pattern very nicely over the course of the day - mostly hourly(ish) with a suddent spike in the number of trains in the afternoon, then a drop off for going home time!

Good effort @johnsmith147 !
 

johnsmith147

Member
Joined
20 Mar 2024
Messages
19
Location
Durham
So I tried this on the Cumbrian coast line - just to get a feel for what it does. In one sense, it's quite a boring graph as there's only really one train at a time going up and down, but the passing place looks about right from memory.

What's also interesting is that it shows the service pattern very nicely over the course of the day - mostly hourly(ish) with a suddent spike in the number of trains in the afternoon, then a drop off for going home time!

Good effort @johnsmith147 !
Thanks! It's nice to test on lines like that because they're fast, but I find there are often gaps in the data that make it show strange things or miss trains entirely... The Harrogate loop or Settle-Carlisle are good too.
 

johnsmith147

Member
Joined
20 Mar 2024
Messages
19
Location
Durham
Just fixed some bugs caused by BST (never occurred to me that such things are problematic), changed the operator colour schemes to match Wikipedia and added horizontal lines to mark the locations of stations. Thanks everyone for continuing to use this.
 

sqwizz

Member
Joined
22 Jul 2024
Messages
71
Location
UK
Good job on this, pretty fun to mess around with.

Might be handy to be able to choose the date before it looks for a train, since if there are no trains today (eg no sunday services), you can't progress any further to be able to pick a previous date.
 

johnsmith147

Member
Joined
20 Mar 2024
Messages
19
Location
Durham
Good job on this, pretty fun to mess around with.

Might be handy to be able to choose the date before it looks for a train, since if there are no trains today (eg no sunday services), you can't progress any further to be able to pick a previous date.
Thanks. Indeed that would be helpful but it would be quite difficult (and very slow) to do this due to the limitations of the data. If you specify a route using a specific train from the RTT code then you can pick whichever date you like, which I think should be OK for most purposes?
 

johnsmith147

Member
Joined
20 Mar 2024
Messages
19
Location
Durham
I asked it to give headcodes, but it didn't show any at all.
It'll only show head codes for trains which are currently active (ones with markers on the live plot) - otherwise it would be a bit of a mess. I can't really think of a neat way around that with a static plot...
 

Top