2

I use Node.js and Concave hull algorithm for isolating UK postcode sectors. This is what I get for now: enter image description here

So now, I need to smooth boundaries to look like this: enter image description here

Does anyone have any idea which algorithm should I use?

Community
  • 1
  • 1
karakulj
  • 123
  • 4
  • 11
  • [Spline](http://en.wikipedia.org/wiki/Spline_%28mathematics%29) variants come into mind – amit Jan 28 '15 at 10:00
  • The problem is that you have multiple disjoint polygons, but want to draw a line *between* them. I could try to represent areas between those polygons, and then "squeeze* them to lines in some way. Or "grow" the polygons until they touch. – phadej Jan 28 '15 at 10:41
  • How would I grow them until they touch? What should I use? – karakulj Feb 11 '15 at 11:13
  • @elektro_pionirka you could search for *polygon offsetting* for growing them and *polygon intersection detection* for detecting whether they touch – nicholaswmin Feb 23 '15 at 18:38

2 Answers2

1

There seems to be a lots of ways of doing this. I'm inclined to cite some kind of bezier interpolation (http://www.antigrain.com/research/bezier_interpolation/).

@amit gave another great clue about how to solve the problem, splines are actually pretty useful for smoothing polygons. See the related question: https://gis.stackexchange.com/questions/24827/how-to-smooth-the-polygons-in-a-contour-map

Hope it helps!

Community
  • 1
  • 1
Ciro Costa
  • 2,455
  • 22
  • 25
1

There are at least 2 approaches to this:

  • Curve fitting algorithms(best for your use case)
  • Rammer-Douglas-Peucker algorithm (simpler to implement)

The Rammer-Douglas-Peucker algorithm reduces the node count of a polygon - this will not smooth it in the sense that it will make it curvy, it will simply reduce the nodes(roughness), whilst struggling to keep the polygon in it's original shape as much as possible

Although what you are, most probably, after is a Curve fitting algorithm through a series of points.

See this answer I've made (and the answer above, which is more descriptive) for solutions to this.

Community
  • 1
  • 1
nicholaswmin
  • 21,686
  • 15
  • 91
  • 167