Roads and Trucks: A Brief Exploration of a Government API
The goal of any data science project is to uncover actionable insights from data. But extracting useful information from a dataset is…
Roads and Trucks: A Brief Exploration of a Government API
The goal of any data science project is to uncover actionable insights from data. But extracting useful information from a dataset is usually barely half the battle. Often times it is difficult to find a suitable data source that adequately covers the entire region of interest while also remaining up to date. This brief article examines a large, daily updated potential data source for geospatial and traffic related data science projects concerning Sweden.
Trafikverket Open Data API
Trafikverket (Swedish Transport Administration) is in charge of the long term planning, development and maintenance of all modes of transportation within Sweden. To fulfill this task it collects vast amounts of data about the how the transport networks in Sweden operate today. This data comes from various sources like traffic cameras and other automatic sensors to train station announcements about incoming and departing trains. Trafikverket also collects its own data with vehicles measuring road and pavement quality for all roads in Sweden. This data is then used to plan for the traffic systems of the future. But not only that, it is also open for the public to access, use, analyze and publish, in the form of Trafikverket Open Data API. This makes it a very interesting data starting point for any traffic project in Sweden.
The data in the API is structured under the headings: Ferry, Railway and Road. In this brief introduction I will only showcase some of the data in the Road section, more specifically the RoadGeometry and RoadData.
Roads in Sweden
As can be guessed from the name, the RoadGeometry table contains the geographic information about the location of all Roads tracked by Trafikverket in Sweden. This data can be seen in the image below.

Roads in Sweden from Trafikverket Open Data API
As shown above, the distribution of roads are quite inhomogeneous. The more densely populated south have a much denser network of roads than the sparsely populated north. We can also note that the further away from the coast the sparser the roads.

Left: The total road length per County divided by the county's area. Right: The speed of an average kilometer of road in each county.
The plots above further highlight the differences between the urban south and the rural north. As we saw in the earlier plot there are a lot more roads in the south of Sweden, especially in the southern most county of Scania. This is shown in the above plot to the left. Conversely, the average speed is in general higher the more rural a county is, with less towns and people there is less reason to slow down. A notable lowest average speed is seen in the county of the capital Stockholm, a highly urbanized area. So, in Sweden, if you want to go fast, go north.
Traffic Type Analysis
In addition to the standard geometry related data of the roads in Sweden, the Open Data API also has access to the data collected by the sensors and utility vehicles. One such metric that is tracked is the Annual Average Daily Traffic (AADT) which denotes the number of vehicles that traversed a given road on an average 24 hours. This metric in and of itself is interesting as it shows which part of the road network is actually in use, but combined with the AADTHeavyVehicles metric, which shows the number of heavy vehicles (trucks and lorries), it gives us even more information.

The radio between annual average number of daily heavy vehicles and the average total number of daily vehicles traversing a given road in the county of Norrbotten in northern Sweden. The locations of the towns Kiruna and Svappavaara as well as the Pajala Iron Mine are also shown. Only roads with an annual average daily traffic higher than 250 vehicles are shown in the plot.
In the image above the ratio between AADTHeavyVehicles and total AADT is shown for each road tracked by Trafikverket in Norrbotten County. It shows that in the urbanized coastal areas the traffic almost exclusively consists of non-heavy vehicles, i.e, passenger cars, motorcycles and the like. However, some areas in the inland stand out as they have a much larger proportion of heavy vehicle traffic. The main interesting route is the one from just south of the Pajala Iron Mine to the town of Svappavaara. This part of the road network has a very high proportion of heavy traffic, for long stretches it reaches almost 40 %. This indicates that there might be some local circumstances along this route that requires the extended use of heavy vehicles.
Since 2018, the Iron has been mined at the Pajala/Kaunisvaara mine by Kaunis Iron AB. According to their website the mined ore is transported by special built trucks from the mine north of Pajala to a freight train station in Svappavaara for further transport to the port of Narvik in Norway. The website also details that the yearly production of iron ore mined reaches the staggering 2.2 million tonnes. All this activity combined with the fact that the area in general is quire rural and therefore has a comparatively low traffic volume, makes this route stand out in the map above.
Another strech of road that has a quite high proportion of heavy vehicle traffic is just south of the city of Kiruna. Upon closer inspection of this area it is seen that this road leads directly to a military training area complete with an airstrip. The transport of military vehicles and supplies on general supply trucks to this base might be the reason for the spike in AADT ratio.

Ratio between the number of heavy vehicles and total number of vehicles traversing a specific road in the area north of Stockholm. Only roads with at least 250 daily vehicles passing are shown. Arlanda Airport and the Vällsta works are also located.
In the above image the same type of map is shown but over the area north of the Swedish capital Stockholm instead. So the fraction of heavy vehicles to total amount of vehicles that on average pass on a given road, with roads with less than 250 vehicles passing each day on average filtered away. In this map there are two main interesting areas.
Firstly, there are two roads leading to Arlanda Airport with a heavy vehicle ratio above 30 % while there are still two roads with the same ratio approaching zero percent. The conclusion to draw from this data is that we have identified the roads utilized by the trucks delivering supplies to the airport. An airport needs a very high volume of supplies to function properly and it is no surprise that a separate set of roads are used for this purpose.
Additionally, the traffic on the road running right by the Vällsta Works consists of about 25 % heavy vehicles. The Vällsta Works is a large recycling and landfill facility north of Stockholm. As such the customers frequenting this place usually use trucks to discard their waste. This can in turn explain the high proportion of heavy vehicle use on the road leading to this place.
Conclusion
Trafikverkets Open Data API provides access to detailed and vast data sets on the traffic networks in Sweden. The geometries of road, rail and ferry routes can be pulled and used for various geospatial data science and engineering projects. In addition to that, many interesting metrics are collected and tracked which could be investigated further on their own, the AADT is just one such metric.
This small project also showcased a potential method of finding interesting facilities that are frequented by heavy vehicles. By comparing the total number of daily vehicles with the number of heavy vehicles on a road certain routes are highlighted that might have some connection with an interesting site. This method could be used to find other similar locations in Sweden.
Even though the information is there in the API it is not always easy retrieve in the desired format. Compiling the dataset used to create the AADT plots required quite some manual effort.
Thank you for reading!
메타데이터
- post_id
- db48de83c596
- slug
- roads-and-trucks-a-brief-exploration-of-a-government-api-db48de83c596
- url
- https://medium.com/@j.backsund/roads-and-trucks-a-brief-exploration-of-a-government-api-db48de83c596
- canonical_url
- https://medium.com/@j.backsund/roads-and-trucks-a-brief-exploration-of-a-government-api-db48de83c596
- author_url
- https://medium.com/@j.backsund
- status
- ok
- fetched_at
- 2026-08-06 06:41:47