py_eddy_tracker.poly.visvalingam

py_eddy_tracker.poly.visvalingam(x, y, fixed_size=18)[source]

Polygon simplification with visvalingam algorithm

X, Y are considered like a polygon, the next point after the last one is the first one

Parameters:
  • x (array) –

  • y (array) –

  • fixed_size (int) – array size of out

Returns:

New (x, y) array, last position will be equal to first one, if array size is 6, there is only 5 point.

Return type:

array,array

import matplotlib.pyplot as plt
import numpy as np
from py_eddy_tracker.poly import visvalingam

x = np.array([1, 2, 3, 4, 5, 6.75, 6, 1])
y = np.array([-0.5, -1.5, -1, -1.75, -1, -1, -0.5, -0.5])
ax = plt.subplot(111)
ax.set_aspect("equal")
ax.grid(True), ax.set_ylim(-2, -.2)
ax.plot(x, y, "r",  lw=5)
ax.plot(*visvalingam(x,y,6), "b", lw=2)
plt.show()

(Source code, png, hires.png, pdf)

../_images/py_eddy_tracker-poly-visvalingam-1.png