API or feed for Miles & Chains/Yards

52 views
Skip to first unread message

John Avison

unread,
Oct 25, 2025, 2:38:09 PM (7 days ago) Oct 25
to A gathering place for the Open Rail Data community
Having used this app shown below, is there anything on the RDM available that would give similar information?
Specifically, I'm looking to find out the miles/chains of a picked location, or at the very least, the miles/chains of each STANOX.
Is there an API or feed available that offer this?

Track Locator APK for Android Download

Peter Hicks

unread,
Oct 25, 2025, 4:51:18 PM (7 days ago) Oct 25
to openrail...@googlegroups.com
Hi John

On Saturday, 25 October 2025 at 19:38, John Avison <in...@shotbyaj.com> wrote:

Having used this app shown below, is there anything on the RDM available that would give similar information?
Specifically, I'm looking to find out the miles/chains of a picked location, or at the very least, the miles/chains of each STANOX.
Is there an API or feed available that offer this?


The ELR shapefiles in there contain a single linestring per ELR with start and end measures.  You can probably use this to approximate the position of a point along a linestring.

For something more precise, you could use the waymarks data - bear in mind that the decimal figures look like miles and yards, so 3.1759 will be a yard away from 4.

There's plenty of support in languages such as Python and even databases (e.g. PostGIS, a spatial extension for PostgreSQL) to handle working with geospatial data.


Peter

Juhani Pirttilahti

unread,
Nov 1, 2025, 5:53:45 PM (8 hours ago) Nov 1
to A gathering place for the Open Rail Data community
Hi John and Peter

This is a school book case of linear referencing. If you are somehow familiar with databases you can use PostGIS and the ST_LineLocatePoint and ST_LineInterpolatePoint functions when converting coordinates to points and vice versa. Software to install are PostgreSQL and the PostGIS extension. Next step is getting and importing the Track Model, just as Peter mentioned.


Generally speaking, you have to find the nearest polyline for your coordinates and then snap the coordinates to the polyline. Not the point belonging to the nearest polyline, but the point where the edge of polyline itself is nearest to the coordinates, to be exact. Then you have to calculate the fractional location (0-1, between 0 and 100%) of that point along the polyline. Then you can use this fractional value to calculate the location based on the start and end position of the polyline. The properties START and END in the model respectively. However, the format is not really a number itself, but always miles and yards separated by a dot: MMM.YYYY. This operation can be done on ELR level (NWR_ELRs.shp) or for more detail on track level (NWR_TrackCentreLines.shp), just choose which one of the files you load into the database. I do hope this is well explained! If not, just ask, I'm glad to help you out.

This is also something I could implement myself. For example, a coordinates to miles and chains (or yards, if some prefer) converter as an API product, if there is sufficient interest. Having six years worth of experience with linear referencing and track asset databases in Finland, this is an easy task for me. (And more fun than typing in details of catenary masts from scanned paper documents dated in the 1960s, happy times.)

Not really knowing the UK law, the copyright is something that worries me though. Looking at the NWR Track Model and its Track Model Technical Specification file it is indicated that there is database copyright owned by Ordnance Survey. Can someone shed some light on this? Is it enough to mention the copyright owner when publishing a product based on NWR Track Model?

Juhani
Reply all
Reply to author
Forward
0 new messages