Skip to content

Map matching in ArcGIS

simonscheider edited this page Feb 17, 2017 · 12 revisions

Map Matcher

Purpose:

This python script allows map matching (matching of track points to a network) in arcpy using a Hidden Markov model with probabilities parameterized based on spatial + network distances. Follows the ideas in Newson, Krumm (2009): "Hidden markov Map Matching through noise and sparseness"

Author: Simon Scheider

Created: 17/02/2017

The code is written in Python 2.7 and depends on:

  • arcpy (ships with ArcGIS and its own Python 2.7)
  • networkx

python pip install networkx

  • note: requires installing GDAL first, which can be obtained as a windows wheel from here and then installed with pip locally:

python pip install GDAL-2.1.3-cp27-cp27m-win32.whl

Usage

arcpy.env.workspace = 'C:/Users/simon/Documents/GitHub/mapmatching'

opt = mapMatch('testTrack.shp', 'testSegments.shp')

#outputs testTrack_path.shp

exportPath(opt, 'testTrack.shp')

The main method is mapMatch. Based on the Viterbi algorithm for Hidden Markov models, see https://en.wikipedia.org/wiki/Viterbi_algorithm. It gets trackpoints and segments, and returns the most probable segment path (a list of segments) for the list of points.

Inputs:

    @param track = a shape file (filename) representing a track, can also be unprojected (WGS84)
    @param segments = a shape file of network segments, should be projected (in meter) to compute Euclidean distances properly (e.g. GCS Amersfoord)
    @param decayconstantNet (optional) = the network distance (in meter) after which the match probability falls under 0.34 (exponential decay). (note this is the inverse of lambda)
    @param decayConstantEu (optional) = the Euclidean distance (in meter) after which the match probability falls under 0.34 (exponential decay). (note this is the inverse of lambda)
    @param maxDist (optional) = the Euclidean distance threshold (in meter) for taking into account segments candidates.

Note:

depending on the type of movement, optional parameters need to be fine tuned to get optimal results.

Clone this wiki locally