algorithminterpolationgeospatialsmoothingspatial-interpolation

How to simplify a spline?


I have an interesting algorithmic challenge in a project I am working on. I have a sorted list of coordinate points pointing at buildings on either side of a street that, sufficiently zoomed in, looks like this:

enter image description here

I would like to take this zigzag and smooth it out to linearize the underlying street.

I can think of a couple of solutions:

  1. Calculate centroids using rolling averages of six or so points, and use those.
  2. Spline regression.

Is there a better or best way to approach this problem? (I am using Python 3.5)


Solution

  • Dali's post correctly surmises that a line simplification algorithm is useful for this task. Before posting this question I actually examined a few such algorithms but wasn't quite comfortable with them because even though they resulted in the simplified geometry that I liked, they didn't directly address the issue I had of points being on either side of the feature and never in the middle.

    Thus I used a two-step process:

    1. I computed the centroids of the polyline by using a rolling average of the coordinates of the five surrounding points. This didn't help much with smoothing the function but it did mostly succeed in remapping them to the middle of the street.
    2. I applied Visvalingam’s algorithm to the new polyline, with n=20 points specified (using this wonderful implementation).

    The result wasn't quite perfect but it was good enough:

    enter image description here

    Thanks for the help everyone!