eyecatch

How Long to the Airport? Drive Time in QGIS

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

What you'll learn


  • How to load OSM data
  • Steps for calculating drive time from road data

Recommended for


  • Anyone who wants to try loading OSM data in QGIS
  • Anyone who wants to use QGIS to calculate drive time from road data

Introduction

The author lives in Hokkaido and one day wondered: “Where in Hokkaido is farthest from an airport?”

Is it the midpoint between Wakkanai Airport and Asahikawa Airport in northern Hokkaido, or somewhere around the center of the Oshima Peninsula in southern Hokkaido?

This article explains how to calculate drive time from road data in QGIS and visualize it.

Load road data into QGIS

Load OSM data into QGIS

Calculating drive time requires road data. This article uses road data from OpenStreetMap (OSM).

For more about OSM, see the article below.

Use the QuickOSM plugin to load OSM data. For installation and usage, see the article below.

Select the Quick query tab, and choose the area to load from the In drop-down menu at the center left. This example uses Canvas Extent (the extent of the QGIS map canvas).

Set the following options:

  • Key: highway, the OSM road tag
  • Drop-down on the left: Or
  • Value: enter motorway (expressway), trunk (national highway), primary (major regional road), and secondary (other major road), plus the ..._link value of each

Then click Run query.

The QuickOSM dialog
The QuickOSM dialog

The process is skipped when there are too many features to load, so narrow the canvas extent or zoom in.

After a few dozen seconds, the road data loads.

Roads loaded by QuickOSM
Roads loaded by QuickOSM

Advanced: process the road data

This section is for readers who want to assign a different speed to each road type.If you want to use one speed for all roads, skip to the next section, “Calculate drive time from the airport.”

In OSM data, the maxspeed tag records the speed limit (maximum speed).

However, many roads have no value. For those, the speed is estimated from the road type and assigned automatically.

The speeds are set as follows: motorway (expressway) = 90 km/h, trunk (national highway) = 70 km/h, primary (prefectural road) = 60 km/h, and secondary (other roads) = 50 km/h.

In the attribute table, open the Field Calculator, create a new field speed, and enter the following expression.

CASE
  WHEN "maxspeed" IS NOT NULL AND "maxspeed" != '' AND "maxspeed" > 0
    THEN "maxspeed"
  ELSE
    CASE
      WHEN "highway" = 'motorway' THEN 90
      WHEN "highway" = 'motorway_link' THEN 60
      WHEN "highway" = 'trunk' THEN 70
      WHEN "highway" = 'trunk_link' THEN 50
      WHEN "highway" = 'primary' THEN 60
      WHEN "highway" = 'primary_link' THEN 40
      WHEN "highway" = 'secondary' THEN 50
      ELSE 30
    END
END

This adds the new speed field and sets a speed for every road.

The new speed field added to the OSM road data
The new speed field added to the OSM road data

Calculate drive time from the airport

Use the QNEAT3 plugin to calculate drive time.

After installing it, select QNEAT3 - Qgis Network Analysis Toolbox in the Processing Toolbox, then double-click Iso-Areas → Iso-Area as Pointcloud (from Point).

Selecting QNEAT3 in the Processing Toolbox
Selecting QNEAT3 in the Processing Toolbox

When the dialog opens, set the following options:

  • Start Point: the starting point of the calculation (click the map to select it)
  • Size of Iso-Area: the reachable range in seconds (enter 3600 for one hour)
  • Optimization Criterion: select Fastest Path (time optimization)
  • Speed field: speed (only if you did the “Advanced: process the road data” step above)
  • Default speed: 50

Then click Run.

The QNEAT3 dialog
The QNEAT3 dialog

This example uses a road near New Chitose Airport as the starting point.

When the process finishes, points appear along the roads around New Chitose Airport. This is the area from which New Chitose Airport can be reached within one hour.

The area reachable within one hour, centered on New Chitose Airport
The area reachable within one hour, centered on New Chitose Airport

If you color by the cost attribute field, you can also display a gradient according to time.

Example of a gradient color scheme by time
Example of a gradient color scheme by time

Find the point farthest from an airport in Hokkaido

Run the same calculation for the other airports in Hokkaido, and merge the results into one layer.

From the Processing Toolbox, select Execute SQL.

Select the data sources you want to merge, then enter and run the code below. It gets the minimum value at each point and merges the layers.

(Add or remove lines of UNION ALL SELECT cost, geometry FROM input○ depending on the number of layers to merge.)

SELECT
  MIN(cost) as min_cost,
  geometry
FROM (
  SELECT cost, geometry FROM input1
  UNION ALL
  SELECT cost, geometry FROM input2
  UNION ALL
  SELECT cost, geometry FROM input3
  … add as many blocks as there are layers to merge
)
GROUP BY geometry

Sort the merged data by min_cost in descending order and select the point with the largest value.

8,879 seconds (2 hours 28 minutes) was the maximum value
8,879 seconds (2 hours 28 minutes) was the maximum value

The point in Hokkaido farthest from an airport is Tomari in Shimamaki Village (near Tomarigawa Kajika-no-yu), at 2 hours 28 minutes (8,879 seconds) from Okadama Airport.

The point in Hokkaido farthest from an airport is “Tomari, Shimamaki Village”
The point in Hokkaido farthest from an airport is “Tomari, Shimamaki Village”

Other points far from an airport include:

  • Sankei, Tomamae Town (2 hours 21 minutes)
  • Kamihaboro, Haboro Town (2 hours 19 minutes)
  • Mountainous areas of Shinhidaka Town, Urakawa Town, and Samani Town

Many of these points are in dead-end mountainous areas between airports.

Style the map

Color coding

To evoke a thermal image, drive time is colored in 30-minute steps: warm colors near an airport, and cooler colors the farther away it is.

Colored in a six-step gradient at 30-minute intervals
Colored in a six-step gradient at 30-minute intervals

Some may say that “near = cool colors” is the more common scheme, but many examples use “near = warm colors,” such as the travel time map Yahoo made in 2015:

Design

The airport icon combines a preset QGIS SVG with a circle. The background map shows coastlines and municipality labels based on National Land Numerical Information data, and the map is complete!

The finished map after styling
The finished map after styling

Bonus: how to calculate closer to real conditions

The first map the author made was calculated with the speed limits in the OSM data, or with maximum speeds estimated from road types. As a result, the author received comments on X saying, “You can’t get there this fast in urban areas.”

So the author decided to use the “average travel speed” data published by the Ministry of Land, Infrastructure, Transport and Tourism (MLIT).

The “average travel speed” is calculated from actual travel times, including waiting at traffic lights and congestion.

Looking at the morning and evening travel speeds across Hokkaido, general national highways (directly managed) run in the 20s km/h in DIDs (Densely Inhabited Districts), in the 40s in urban areas, and in the upper 50s in flat and mountainous areas. Even on the same road, speeds differ greatly depending on the area.

From MLIT, “Fiscal Year 2021 (Reiwa 3) Nationwide Road and Street Traffic Census, General Traffic Volume Survey, Summary Tables”
From MLIT, “Fiscal Year 2021 (Reiwa 3) Nationwide Road and Street Traffic Census, General Traffic Volume Survey, Summary Tables”

Using this as a reference, the values in the table below were applied. The road data was split into the parts that overlap a DID and the parts that do not, and each part was given the corresponding average travel speed.

Road type DID Non-DID
motorway (expressway) 60 km/h 80 km/h
trunk (national highway) 40 km/h 60 km/h
primary (major regional road) 30 km/h 50 km/h
secondary (other major road) 20 km/h 45 km/h

The image below compares results calculated with the previous “speed limit (maximum speed)” (left) and the “average travel speed” (right). The reachable area narrows, especially for routes through urban areas, and the result appears closer to actual conditions.

Comparison of results for the Kanto region calculated with speed limits and average travel speeds
Comparison of results for the Kanto region calculated with speed limits and average travel speeds

If you need more accuracy than this, you may need to use actual probe data, congestion information, and the like.

Conclusion

Finally, a nationwide map was also created from the data calculated with the “average travel speed.”

Outside Hokkaido, light blue to blue areas that take two hours or more spread across places such as northern Gunma Prefecture, the Izu Peninsula, and western Kochi Prefecture.

<a href="https://x.com/chizutodesign/status/1991103250314224025" target="_blank">Airport travel time map of Japan</a>
Airport travel time map of Japan

This shows that QGIS can calculate drive time from OSM road data and visualize it.

This time, the calculation used only standard QGIS features, but there are also more specialized analysis methods.

If you are interested, be sure to read the explanatory article by @geogra as well!

Data sources

About the author
Hajime Kato, MIERUNE Inc. (地図とかデザインとか)
Hajime Kato, MIERUNE Inc. (地図とかデザインとか)

After working at a design studio, joined MIERUNE Inc. in Sapporo, Hokkaido, as a graphic designer. Publishes works, mainly maps and route maps, on social media such as X (formerly Twitter) under the name 地図とかデザインとか (roughly, “Maps and Design and Such”).