DEV Community

Cover image for Let's try the HERE Route Matching API QGIS Plugin
Patrick Yuen for MIERUNE

Posted on

Let's try the HERE Route Matching API QGIS Plugin

Original article (Japanese): https://qiita.com/Kanahiro/items/7d588f238df9be1e8eea

Image description

Introduction

In the world of GIS, there is a technique called “map matching” or “route matching”, which fits GPS or other location data to roads.

Image description

The simplest way to explain the technique of “route matching”, is that it is the operation used to move a point to the closest geographic feature. However, as shown below, it is not possible to create a suitable path simply by moving points. Matching based on the order of the points, and the deviation of each point is required.

Image description

Route searching technique is necessary to solve this problem. Through some Googling, you may find that some people would suggest creating your own route searching server. However, it is a difficult task for not only ordinary users of GIS, but also GIS technicians and engineers. However, this operation can also be interpreted as “inputting a series of points, and receiving the most likely line”, and there are multiple services that provides WebAPI for such an operation.

MIERUNE, which is great at developing QGIS plugins developed a plugin that uses such services to implement route matching in QGIS. In developing the plugin, we decided to use the HERE API, which is thought to be the strongest in route searching technology. This article discusses the technical details and how to use the HERE API plugin.

About HERE’s API

HERE publishes a wide range of APIs on location information and services, including APIs for maps, geocoding and route searching. HERE even publishes 5 APIs for route searching, which are shown below. (excluding the 2 deprecated APIs, as of July 2022)

  • HERE Routing API v8 (For route searching)
  • HERE Isoline Routing API v8 (For calculating service areas)
  • HERE Matrix Routing API v8 (For calculating routes when there are multiple points of departure and arrival)
  • HERE Route Matching v8
  • HERE Waypoints Sequence v8 (For solving the traveling salesman problem)

When only the types of APIs are considered, Mapbox also provides the same types of API. However, HERE’s route searching service also considers the realtime state of the traffic lights, search for routes that trucks can pass through, and even take in mind the range of electric vehicles (EV). It can be said that HERE’s API has a wide range of functionalities that are focused for logistics and transportation companies.

The plugin that we developed uses the HERE Route matching v8 API, and if there is demand for other plugins, we are also considering the development of plugins for the other APIs as well.

HERE Route API plugin

GitHub logo MIERUNE / qgis-here-api-plugin

QGIS Plugin for HERE Route API

HERE Route API Plugin

icon

QGIS Plugin for HERE API.

QGIS Python Plugins Repository

Installation

Get Plugin

Authentication

  • Get API Key from HERE Platform.
  • From the menu bar, select Plugin -> HERE Route API Plugin -> Config and enter your API Key. config

Functions

1. Route matching

  • Match any points in order to the most probably path, using the HERE Route Matching API. mov

Usage

  • Select Plugin -> HERE API Plugin -> Route Matching from the menu bar.
  • Select a point layer.
  • Select a sort field. (optional, default to fid)
  • Select a route matching mode from car, bus, bicycle or pedestrian.
  • Click OK and the trace will be added to the map canvas as a temporary layer. dialog export

Note
This plugin can help you to match the trace of a large dataset, which including more than 400 points. However…


QGIS has to be install prior to using the plugin. Although the plugin works for any version of QGIS that starts with 3, we suggest using the latest LTR of QGIS, as the plugin may not work in versions that are too old.

Manual for the plugin

Install

  1. Open “manage and install plugins”
    Image description

  2. Search for HERE in the list of QGIS plugins and install the HERE Route API Plugin
    Image description

  3. Confirm that the HERE Route API Plugin is installed in the plugin menu
    Image description

Setting up the API key

  1. Get an API key at HERE Platform
  2. From the menu bar, open "Plugin", "HERE Route API Plugin", "Config", insert your API key and click on "OK" Image description

Image description

Route matching

Image description

Route matching for this plugin conducts operations in which “The plugin takes any point layer as input, and outputs the likeliest line layer”. Because of the operation conducted by the plugin, this manual considers that a point layer exists in the QGIS project. (However, the number of features in the point layer is less than 10,000) The following explanation takes the point layer in the above image as the input. Moreover, as the API may only take 400 features at once, the request will be divided when the input layer has more than 400 features. More specifically, the plugin sends 400 features in each request, and then combine the results given by the APIs. From the menu bar open “plugin”, “HERE Route API Plugin”, and then “Route Matching”.

Image description

  1. Select the target point layer in the Layer pulldown list
  2. From the Sort Field pulldown list select the field that contains the order in which the points are lined up in (Optional, if it is empty, the fid field will automatically be used
  3. From the Mode pulldown list, select car, bus, bicycle or pedestrian
  4. Click on OK to start the operation
  5. When the operation is finished, the results will be shown

Image description

With some acceptable deviations, the likeliest route that the points took will be shown.

Image description

Conclusion

Actually, the Route Matching API accepts a large amount of parameters. The input parameters used in the plugin is only the most general few of them. It is very difficult to utilize all of the input parameters, which also shows that the API supports a variety of use cases. As the QGIS plugin introduced in this article only covers a part of the functionalities, please also try the API yourself!

Top comments (0)