Re: intersection/union of two polygons [message #33741 is a reply to message #33736] |
Thu, 23 January 2003 08:10   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Roberto Monaco (rmonaco@coresw.com) writes:
> Does anyone know where I can find intersection and union between two
> polygons in IDL?
>
> Ideally a function that returns the polygon resulting of the intersection
> (union) of the input polygons. If not, the area (intersection / union) would
> be helpful.
If the polygons are in the same plane, and you want
a purely graphical solution (in the sense of pixel
values), then you could try this:
1. Find the indices in each polygon with POLYFILLV.
2. Find the intersection or union of the two indices
vectors with SetIntersection or SetUnion from my
web page:
http://www.dfanning.com/tips/set_operations.html
You will probably have to add some rudimentary error
checking to the programs you find here.
3. Find the boundary around this set of pixels with
Find_Boundary. (And, possibly, Label_Region if there
is more than one contiguous region in the union. Ben
Tupper has send me a program that does this automatically,
I think, if I can find it in the chaos around here. Let
me know if you think you need it.)
http://www.dfanning.com/programs/find_boundary.pro
Find_Boundary can return the area as well as the perimeter,
in addition to specifying the polygon of the result.
This idea may not be anything like what you want, but
the advantage is that it is simple. :-)
Cheers,
David
--
David W. Fanning, Ph.D.
Fanning Software Consulting, Inc.
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|