in reply to Merging Polygons

Hi,
I'm not quite sure exactly how you're thinking of merging adjacent polygons (i.e. are they touching?) but this module seems to have the sort of polygon manipulation routines you would require to do this.

Regards Paul.

Replies are listed 'Best First'.
Re^2: Merging Polygons
by gnu@perl (Pilgrim) on Mar 30, 2005 at 13:44 UTC
    I have had to do this exact same thing previously. Are you doing GIS work? What type of data are these 'points'? Are they simple graph plots, lat-long pairs, etc? Even if you are not doing GIS work do a google search on 'gis perl' or start at http://freegis.org You can basically do this:
    1 ......... 2 . . 3 . ........ 4 . . . 5 . . . 6 . ........ 7 . . 8 ......... 1234567891111111 0123456
    Given the two adjacent polygons above, you essentially want to remove the points between 9,6 and 9,3. All you need to do is sort each list of points and remove the matching set. Be sure to leave the 'leftmost' and 'rightmost' matching set though. I would do as suggested and order each polygon either clockwise or counter clockwise. This should work out just fine for you. If you need more clarification or help, just ask. If done carefully, you will end up with the following. Please correct me if I'm wrong in my assumptions.
    1 ......... 2 . . 3 . ........ 4 . . 5 . . 6 . ........ 7 . . 8 ......... 1234567891111111 0123456
Re^2: Merging Polygons
by Anonymous Monk on Mar 30, 2005 at 00:49 UTC
    Yes...they would be touching.
Re^2: Merging Polygons
by tall_man (Parson) on Mar 31, 2005 at 00:31 UTC
    I second the recommendation for the module Math::Geometetry::Planar, especially the GpcClip UNION operation. It is capable of dealing with concave polygons and polygons with holes.