Re: Polygon Smoothing [message #70823] |
Tue, 11 May 2010 06:52 |
KRDean
Messages: 69 Registered: July 2006
|
Member |
|
|
On May 10, 12:02 pm, 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
>
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming:http://www.dfanning.com/
> Sepore ma de ni thue. ("Perhaps thos speakest truth.")
How about a Douglas-Peucker Algorithm?
Brad Gom submitted POLY_SIMPLIFY.pro into ITTVIS' Code Library that
uses this approximation algorithm.
Smooth Sailing!
Kelly Dean
Fort Collins, CO
|
|
|
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.
|
|
|
Re: Polygon Smoothing [message #70832 is a reply to message #70831] |
Mon, 10 May 2010 13:03  |
Kenneth P. Bowman
Messages: 585 Registered: May 2000
|
Senior Member |
|
|
In article <MPG.2651f81de68373869896d4@news.giganews.com>,
David Fanning <news@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
|
|
|