Re: Polygon Smoothing [message #70831 is a reply to message #70823] |
Mon, 10 May 2010 15:46   |
Karl[1]
Messages: 79 Registered: October 2005
|
Member |
|
|
On May 10, 2:03 pm, "Kenneth P. Bowman" <k-bow...@null.edu> wrote:
> In article <MPG.2651f81de6837386989...@news.giganews.com>,
> David Fanning <n...@dfanning.com> wrote:
>
>> Folks,
>
>> I have a shape file describing a 2D polygon that is *extremely*
>> complex and detailed. For my puposes, overly so. I would like
>> to "simplify" or "smooth" this polygon to make it more suitable
>> for my purpose (using it as a cookie-cutter for extracting data).
>> Has anyone written a polygon smoothing routine, possibly using
>> Bézier curves, in IDL to do such a thing? Would you be willing
>> to share it?
>
>> Thanks,
>
>> David
>
> One simple algorithm is to traverse the polygon and remove
> points that are nearly collinear. For any three sequential
> points you can get the angle at the middle point from the
> dot product. If the curvature is less than some threshold,
> remove the middle point. You probably want to check the
> distance between the points as well as the curvature.
>
> Apply repeatedly until satisfied.
>
> Ken
MESH_DECIMATE does this very well.
You might have to run the shape through IDLgrTessellator to generate a
mesh and get rid of any concavities or self-intersections that
invariably come up at the worst time in Shape files.
Then run it through MESH_DECIMATE. I think you can tell it to NOT
generate any new vertices, as it might do to get the optimum
solution. You can also pass it a "percentage" which will control the
amount of smoothing.
The resulting mesh will then contain a subset of your original
vertices. All you have to do is walk the connectivity list to pull
out the vertices that represent your outline.
|
|
|