Simplification#

We present on this page four filtering algorithms for track by using Douglas & Peucker simplification, Visvalingram simplification, squaring algorithms and …

The process “Track simplification” generally returns a new simplified track. Tolerance is in the unit of track observation coordinates.

Generic method#

tracklib.algo.Simplification.simplify(track, tolerance, mode=1, verbose=True)[source]#

Generic method to simplify a track. The process “Track simplification” generally returns a new simplified track. Tolerance is in the unit of track observation coordinates.

Differents modes of simplification are implemented in tracklib:

  • MODE_SIMPLIFY_DOUGLAS_PEUCKER (1)

    tolerance is max allowed deviation with respect to straight line

  • MODE_SIMPLIFY_VISVALINGAM (2)

    tolerance is maximal triangle area of 3 consecutive points

  • MODE_SIMPLIFY_SQUARING (3)

    tolerance is threshold on flat and right angles

  • MODE_SIMPLIFY_MINIMIZE_LARGEST_DEVIATION (4)

    tolerance is typical max deviation with respect to straight line

  • MODE_SIMPLIFY_MINIMIZE_ELONGATION_RATIO (5)

    tolerance is typical elongation ratio of min bounding rectangle

  • MODE_SIMPLIFY_PRECLUDE_LARGE_DEVIATION (6)

    tolerance is max allowed deviation with respect to straight line

  • MODE_SIMPLIFY_FREE (7)

    tolerance is a customed function to minimize

  • MODE_SIMPLIFY_FREE_MAXIMIZE (8)

    tolerance is a customed function to maximize

Application#

We use the same sample track in the different examples. For loading the data:

from tracklib.io.TrackReader import TrackReader
import tracklib.algo.Simplification as Simplification

chemin = './data/lacet/ecrins.csv'
tracks = TrackReader.readFromWkt(chemin, 0, 1, 2, ",", 1,
                                  "ENUCoords", None, True)
trace = tracks["903959","%"][0]
trace = trace.extract(70,120)

trace.summary()

Douglas-Peucker (1)#

The Douglas-Peucker algorithm reduce the number of a line by reducing the number of points. The result should keep the original shape.

Example:

tolerance = 20
trace2 = Simplification.simplify(trace, tolerance,
           Simplification.MODE_SIMPLIFY_DOUGLAS_PEUCKER)
trace.plot(append = False, sym='g-')
trace2.plot(append = True, sym='b-')
../../_images/simplify_douglaspeucker.png

Figure 2 : Simplification with Douglas Peucker#

Note

Reference: David Douglas, Thomas Peucker: Algorithms for the reduction of the number of points required to represent a digitized line or its caricature. In Cartographica: The International Journal for Geographic Information and Geovisualization. Volume 10, Issue 2, Pages 112–122, 1973, https://utpjournals.press/doi/10.3138/FM57-6770-U75U-7727

Visvalingram (2)#

The Visvalingram algorithm simplify the geometry of the track by reducing the number of points but the result presents less angular results than the Douglas-Peucker algorithm.

Example:

tolerance = 50
trace3 = Simplification.simplify(trace, tolerance,
           Simplification.MODE_SIMPLIFY_VISVALINGAM)
trace.plot(append = False, sym='g-', label='original track')
trace3.plot(append = True, sym='b-', label='simplify:visvalingam')
plt.legend()
../../_images/simplify_visvalingam.png

Figure 1 : Simplification with Visvalingram#

Note

Reference: M. Visvalingam & J. D. Whyatt (1993) Line generalisation by repeated elimination of points, The Cartographic Journal, 30:1, 46-51, DOI: 10.1179/000870493786962263

Squaring algorithm (3)#

Function to simplify a GPS track with squaring algorithm.

Example:

tolerance = 3
trace1 = Simplification.simplify(trace, tolerance,
           Simplification.MODE_SIMPLIFY_SQUARING)
trace.plot(append = False, sym='g-')
trace1.plot(append = True, sym='b-')
../../_images/simplify_squaring.png

Figure 3 : Simplification with squaring algorithm#

Note

Reference: Lokhat, Imran & Touya, Guillaume. (2016). Enhancing building footprints with squaring operations. Journal of Spatial Information Science. 13. 10.5311/JOSIS.2016.13.276