Skip to content

Running at night: Avoiding unlit streets

Published 2020-02-17


When I first started tinkering with Trail Router and mentioned the idea to friends, one thing I heard a few times was "Cool idea, but I can only run after work - it's too dark and I don't know if it's safe."

The people I was talking to would often reference uncertainty over safety as a reason for not going for a run at night. 'Safety' is quite a subjective word, so clearly there was no one-size-fits-all approach, but I decided to look into whether source data existed that might allow Trail Router to help.

Naturally, I looked first at Openstreetmap and saw that roads were tagged with a 'lit' flag, which indicated whether the street included lighting. This seemed like a good start!

Avoiding unlit streets

Trail Router now includes an option to 'Avoid unlit streets' in the settings menu. This does two things when checked.

Firstly, an overlay will appear on that map depicting which streets are lit. This looks especially nice when used in conjunction with the 'dark mode' map (see below).

Secondly, after enabling 'Avoid unlit streets', the Trail Router algorithm will try its hardest to avoid using any streets without lighting. In the center of big cities this might be very easy, but even a few miles out of a city it's pretty difficult. The algorithm will still route over streets without lighting, but only if a well-lit street is unavailable.

Avoiding unlit streets

Before and after. Left: The default 'green' algorithm takes us along the River Thames, around the Greenwich Peninsula, which is unlit. Right: The 'Avoid unlit streets' option is enabled and we now take the well-lit roads, avoiding the unlit river route.

Internally, the 'Avoid unlit streets' feature works very similarly to the greenery/nature routing option. An index of how well-lit each street is is generated and is used as a weighting input into the routing algorithm.

Future work around safety

I'm very happy with how the point-to-point routing algorithm is working in conjunction with the 'avoid unlit streets' feature. However, the round-trip routing algorithm could use some improvements. Whilst the round-trip routes it suggests will certainly prefer well-lit streets, they are sometimes more complicated than necessary. I'd suggest clicking through a few options to find one that suits you.

I also hope to introduce additional safety focused features into Trail Router in the future. Realtime tracking of other users of other Trail Router users following the same route is something I'd like to explore. This would have been particularly useful to me recently on a long trail run when our group got split up.

One suggestion I received was to use publicly available crime statistics to avoid routing via high-crime areas. This seems like a double edged sword - if everyone routing app avoided such areas then surely we'd be perpetuating the problem and they'd struggle to ever improve. I'm undecided on this.


Hopefully the 'Avoid unlit streets' feature and the visual depiction of lit streets will help some would-be runners to give night running a try. Of course, the presence of street lighting alone does not guarantee safety, so keep your wits about you.

Happy night running!