Offline-MapMatching

This plugin matches a trajectory as a point layer with a network as a linestring layer based on a Hidden-Markov-Model and the Viterbi algorithm. There are also routines for preprocessing the data to improve the computation time for the map matching.

Network-Layer:

This combobox shows all visible layers of the current QGIS project with the geometry type LINESTRING. The network, needed to match the trajectory on it, shall be selected. It is recommended, that this layer should be a clean graph following a node-edge-model, i.e. different lines should only touch other lines, never cross them. You can get souch a clean graph e.g. by running the PostGIS function "CreateTopology".

Trajectory-Layer:

The combobox shows all visible layers of the current QGIS project with the geometry type POINT. The trajectory, which will be matched with the network, shall be selected.

Trajectory-ID:

The combobox shows all fields of the chosen trajectory layer. The selected field will be added to the result features, so that the vertices of the result layer can be referred to the points of the trajectory.

CRS of output layer (EPSG):

Insert the EPSG code, which should be used for the result layer. It is recommended to insert the CRS of the network and trajectory layer (both layer should have the same CRS). It is also recommended to use a metric CRS.

Maximum Search Distance [m]:

The maximum distance to find points on the network for each trajectory point. It is mandatory, that this value is greater oder equal than the highest shortest distance between all trajectory points and the whole network. This setting has a big influence on the computing time. Go to the repository on GitHub for further information about this setting.

Standard Deviation:

The standard deviation of the distance between the positions from the trajectory and their possible positions on the network. It will be assumed, that the points of the trajectory and their possible positions are normal distributed. A larger value represents less trust in the measurement. Go to the repository on GitHub for additonal information about this setting.

Expected Value:

The expected distance between the positions from the trajectory and their possible positions on the network. It is recommended to choose the value 0, i.e. ideally, the trajectory points should be on the network, if the accuracy of the coordinates would be 100%.

Transition Weight:

A weight for the calculation of the difference between the distances of two following trajectory points and their corresponding points on the network. A larger value represents more tolerance of non-direct routes. Go to the repository on GitHub for additonal information about this setting.


The plugin runs the following tasks:

read the input layers

calculate candidate points for each trajectory point using the maximum search distance and create a graph of candidates

calculate the probability for each candidate point to be emitted by the correpsonding trajectory point

calculate the similarity of the transitions compared to the trajectory points

find the best candidates using Viterbi algorithm

create a layer of linestrings using this candidates


A detailed description about the algorithm is provided in the README document of the project on GitHub.