All projects

project Published

Estimating Belgrade traffic.

I used HERE’s road speeds and TomTom’s Berlin index to estimate congestion in Belgrade.

Project date
September–November 2026
Tools
OpenAI Codex, HERE API
Original article language
English

I was browsing the websites of GIS companies, as one does, and on TomTom’s website I found a simple yet appealing product: the Traffic Index.

Congestion here is the percentage delay compared to free-flowing traffic. At 50% congestion, a trip that would have taken 10 minutes on an empty road now takes 15. The score can also go above 100%, which, I assure you, is fine. At 150%, the same trip takes 25 minutes.

The index has all sorts of nice infographics, but what I’m most interested in is this one:

TomTom’s hourly speed and congestion level chart for Berlin

I rushed to find Belgrade, but alas, coverage of the public part of the Traffic Index is limited to the usual suspects. There is a gaping hole in the former Yugoslavia.

TomTom’s public Traffic Index coverage map for Europe

I guess it’s up to me to do Belgrade.

For the data source, I chose HERE. Their Base Plan includes 5,000 free traffic requests a month. Each request returns congestion values for roads within a bounding box. It’s enough to accommodate a request every 15 minutes. The problem is, how do I get one number from thousands of road-level traffic estimates?

That’s where the TomTom data comes in.

I decided to build a parametrised model for data aggregation.

For each road segment, HERE provides its length, the reported average speed on that segment at the time of the request, and its free-flow speed. Dividing the length by each speed gives us the travel time along the segment under current and free-flow conditions, respectively.

1. Travel times for segment i

ti = Li vi , ti,free = Li vi,free .

Then there are also road classes. Five in total, from 1 being a highway to 5 being a gravel road. We sum the current and free-flow travel times separately for each class.

2. Total travel times for road class c

Tc = ∑i∈c ti , Fc = ∑i∈c ti,free .

Now we actually introduce the parameters. We’re going to have five weights, one for each road class. To get the congestion score, we take the ratio of the weighted current and free-flow travel times, subtract one, and convert it to a percentage.

3. Congestion score for the snapshot

H=100 ( ∑c wcTc ∑c wcFc −1) .

Here, wc is the weight for road class c. We fit those weights to TomTom’s scores.

So we actually learned how much each road class should impact the overall score. Giving each road segment its own weight could lower the bias and raise the variance, which might have been worth it, but it wouldn’t be generalizable to other cities.

I decided to fit the model on Berlin data first. I started saving quarter-hourly samples from the HERE API to R2 and manually saving hourly series from the TomTom website itself. In a couple of weeks, I had enough data for a prototype.

I was too lazy to automate the TomTom scraping and wasn’t diligent about doing it manually, so I trained the model on two disjoint weeks across October and November and tested it on 13–18 November.

TomTom’s live congestion level and the HERE-based estimate for Berlin, 13–18 November 2026

It turned out pretty good! At rush hour, our prediction overshoots the target on weekdays and undershoots on weekends, so there’s something going on. I want to learn just the road class weights, so I’m not going to chase MAPE with a more flexible model.

OK, now let’s actually do what we’re here for. I’ve been collecting HERE’s Belgrade data for those six days as well, so here goes nothing.

Estimated congestion in Berlin and central Belgrade, 13–18 November 2026

What is this?

I mean, admittedly, I don’t have any target data for Belgrade to evaluate the result against, except that I was on the road on Wednesday during the evening rush! It was dire. There was a long spell of heavy rain with a thunderstorm after dark, and the jams were the worst I’ve seen here, possibly ever. The prediction hits 57.4% at its worst, but I was delayed by at least 80% compared to late at night.

Sampling bias, I know. I have only ridden one route. But it can’t be worse in Berlin. At least that evening.

If I had financial stakes in this analysis, I would try my best to evaluate and iterate. But I have emotional stakes! So I am committing the sin of moulding data to suit my vision. I’m throwing out class 5 roads.

Estimated congestion in Berlin and central Belgrade after excluding class 5 roads

Oh yeah, I feel vindicated. This months-long project was worth it after all. More to the point, it makes sense, as class 5 roads account for 56% of the summed free-flow travel time in Belgrade and only 9% in Berlin. Might be a discrepancy in their definition, or just the cities being that different.

And it’s not as bad as it looks, either. Throwing out class 5 roads was literally my first idea, so I probably didn’t overfit too hard.

That concludes the project as I envisioned it initially. However, I have already started on a follow-up. I’m continuing to collect Belgrade data, and I will soon put together a service that displays congestion in real time as well as a two-hour forecast. So that I never have to sit in that jam again!