Given MCQN Ltd has an interest in maps, data, transport and cities, I was naturally interested to hear about Mapzen’s new TransitFlow tool. It’s some code to hook together some of their open data APIs in order to visualise public transport in a given area.

It’s written in the Python programming language, so I thought it would be something to try out at HiPy’s most-recent python meetup.

By the end of the event I had the basics up and running and had a video showing most of the trains moving around the Liverpool city region.

However, some of the datasets had failed to download or process successfully. Over the rest of the week as a background task (it takes upwards of an hour to run the tool, so it’s been a case of try something, kick off a run, then go back to other work while it runs) I’ve been digging into the issues with that and ironing them out.

One problem was with the transit.land service timing out before returning the data. Dropping the number of results it asked for improved that, but at the expense of more requests to their API. In order not to hammer their service, I ended up with special cases in the code for the most problematic operators (in this case, o-gc-northernrail and o-gc-eastmidlandstrains).

The other issue was with the datasets provided to transit.land rather than their service. For some reason the Cumfybus dataset includes mention of a bus stop in the timetable data which isn’t then in the set of bus stop locations. Unfortunately, when it hits that bug, the TransitFlow script ends up discarding all of the data for that operator. I’ve submitted an issue so that they’re aware of it, and can hopefully make the script a bit more robust. I worked round it by giving any errant stops a fictitious location, which works for this dataset but might not be a generalised fix.

Anyway, with those mods I could generate some nice animations of the train data across Merseyside:

Does this train move on Merseyside? from MCQN Ltd on Vimeo.

And zoomed in to just cover the centre of Liverpool…

Train movements in Liverpool from MCQN Ltd on Vimeo.

You might notice the distinct absence of any buses or ferries—at least over Liverpool.

That seems to be a lack of data in the transit.land service. Looking at this visualisation of just the operator Cumfybus it looks suspiciously like the data is only being generated for Greater Manchester. That, coupled with some the South Lancashire data would explain the bus traffic round the fringes of the videos. I’ve opened this issue on the Liverpool issue tracker for us to work on improving the datasets.

However, it’s still interesting to look at how the trains move around and beyond the city. When there’s some bus data I’d like to see if it can be colour-coded to show the different operators, and see if that tells us anything about their services. Plus this is timetabled data, rather than live data. Being able to overlay live data, or shade the vehicles to show whether they’re running early, late, or on time would give us yet another perspective on how people can get around.