Skip to main content

Hi,

I would like to merge polygons based on area up to a certain point. For example if I had 1000 polygons I would like to reduce that number to 100 keeping them as close as possible in size to one another. Does anyone know if this is possible in FME?

Thanks for any help!

B

This looks like a great challenge. I guess you want to only merge polygons that touch each other?

 

So if there is 1 polygon with size 100 and one polygon with size 150 and both touch 4 polygons with size 10, 15, 20 and 25. You want to join the polygons with 15, 20 and 25 to the first and the size 10 to the second?

100+15+20+25 = 160

150+10 = 160

That means for every small polygon you need to look if joining with a large adjacent polygon does not exceed the average of the total area divided by 100 + your tolerance?

So I guess you should first try it by hand for 2 or 3 random polygons and figure out what criteria you use to add a polygon. Would you start with the largest that is at least below the average goal? Or would you start with the smallest and work your way up?


That’s a tough one. What I would do is start with the SpatialSorter transformer. These will put the polygons in an order where they will be adjacent. Then pass the data into a custom transformer with a loop. Dissolve polygons together in the loop and measure the area, exiting the loop when it gets to your chosen size.

I mean, there are lots of variations depending on your exact circumstances, but that’s how I would at least start out.


Thanks for both of your input. I’m trying to learn how to use loops, so I’m creating a basic dissolve loop. However, no matter how many iterations I set it to run for. It seems to go on infintely. Also, although the loop is set to ‘loop’ back to the ‘Looped’ input, it seems to keep looping back to the ‘input’ transformer.

I’ve attached both the workbench and the shapefile I have been using for this test, any help would be much appreciated.

Thanks

B


Reply