eyecatch

Counting Hokkaido's Traffic Signals with QGIS

Published: Last updated:
This article uses QGIS 3.40. The current LTR is 3.44.

What you'll learn


  • How to load OpenStreetMap traffic signal data
  • How to count traffic signals using the data

Recommended for


  • Anyone who wants to try loading OpenStreetMap data in QGIS
  • Anyone who wants to use QGIS to count features by municipality

Introduction

Traffic signals are a familiar sight, but have you ever wondered how many are installed in your own municipality? For many people, signals are simply part of the scenery, and their number rarely comes to mind.

In rural areas, there are far fewer signals than in cities. Some drivers have gone about an hour without stopping at a red light even once.

This article uses QGIS and OpenStreetMap data to count the traffic signals in each municipality of Hokkaido.

Get the data

Get the traffic signal data

First, get the point data for traffic signals. Point data for traffic signals is not published as open data, so this article uses OpenStreetMap.

Use Overpass Turbo, a tool for downloading OpenStreetMap data, to get the traffic signal data for Hokkaido. Copy the following code into the editor and run it. The code defines an area named 北海道 (Hokkaido) and searches for all nodes (traffic signals) in that area that have the tag 'highway'='traffic_signals'.

[out:json][timeout:25];
area["name:ja"="北海道"]->.a;
node(area.a)["highway"="traffic_signals"];
out body;
>;
out skel qt;

After a short wait, the results appear on the map. Once the data loads correctly, click Export at the top of the screen and download it in GeoJSON format.

Downloading the traffic signal data with Overpass Turbo
Downloading the traffic signal data with Overpass Turbo

To learn more about OpenStreetMap, see the following article.

Get the administrative area data

Because the signals are counted by municipality, next download the administrative area data from National Land Numerical Information. This article uses the data for Hokkaido for fiscal year 2025 (Reiwa 7).

Getting the administrative area data
Getting the administrative area data

Count the traffic signals

Load the traffic signal data

When the data is ready, drag and drop the downloaded traffic signal GeoJSON file into QGIS.

Loading the traffic signal data
Loading the traffic signal data

The attribute table shows 9,718 features. This means that OpenStreetMap has 9,718 traffic signals registered in Hokkaido.

Attribute table of the traffic signal data
Attribute table of the traffic signal data

According to the Hokkaido Prefectural Police's “Individual Facility Plan for Traffic Safety Facilities,” Hokkaido has about 13,000 traffic signals. This suggests that about 3,000 signals are not yet registered in the OpenStreetMap data.

Number of traffic signals in Hokkaido (source: Hokkaido Prefectural Police Individual Facility Plan for Traffic Safety Facilities)
Number of traffic signals in Hokkaido (source: Hokkaido Prefectural Police Individual Facility Plan for Traffic Safety Facilities)
OpenStreetMap map data is updated daily by volunteers around the world. As a result, the level of detail and accuracy varies by region.

Load and preprocess the administrative area data

Next, add the administrative area data downloaded from National Land Numerical Information to QGIS.

Loading the administrative area data
Loading the administrative area data

The attribute table shows 9,555 features. Even within the same municipality, the data has a separate polygon for each ward and each detached area.

Attribute table of the administrative area data
Attribute table of the administrative area data

This article counts signals by municipality, so dissolve the data by the N03_004 attribute, which holds the municipality name. For the detailed steps of dissolving, see the following article.

After dissolving, the data has 184 features.

Attribute table after dissolving
Attribute table after dissolving

Count traffic signals by municipality

Now that the data is ready, count the signals in each municipality. From the Processing Toolbox, open Count points in polygon.

Opening Count points in polygon
Opening Count points in polygon

When the Count points in polygon dialog opens, set the following options:

  1. Polygons: the administrative area layer dissolved above
  2. Points: the traffic signal layer
  3. Click the Run button
The Count points in polygon dialog
The Count points in polygon dialog

When the processing finishes, QGIS outputs the administrative area layer with the name Count.

Check the results

Now check the results. Open the attribute table of the output layer. The NUMPOINTS column at the far right holds the counts.

In the attribute table, Sapporo has the most signals in Hokkaido, with 3,179, followed by Asahikawa with 1,042 and Hakodate with 642. As you would expect, municipalities with larger populations tend to have more signals.

Attribute table of the counting results
Attribute table of the counting results

Next, narrow the view to the cities of Hokkaido. For how to use filters, see the following article.

The city with the fewest signals is Utashinai with 3, followed by Yubari with 7. These numbers come from OpenStreetMap data, so whether they reflect reality needs to be checked. Still, it was surprising to find so few signals at the city level.

Counting results for cities only
Counting results for cities only

Finally, a choropleth map was created from the counting results.

Hokkaido traffic signal map
Hokkaido traffic signal map

Conclusion

This article showed how to use OpenStreetMap and QGIS to count traffic signals by municipality in Hokkaido. Analyses of familiar topics based on open data, like this one, are easy for anyone to start. The same method works for features other than traffic signals, so try it with a variety of data.

Data sources

About the author
QGIS LAB Editorial Team
QGIS LAB Editorial Team

QGIS LAB is a comprehensive information hub for QGIS, the open-source GIS software. Under the concept of “Geospatial for Greater Good,” we share the knowledge and skills to open up the world through location data.