Question

Dissolve adjacent polygons based on sum of an attribute


Badge +1

Hi all, I have a situation where I want to dissolve adjacent tile polygons based on a count value. For the example below I would expect the total sum to be no more than 100. Less is fine. The less polygons I end up with the better, but optimization (doing several passes) to figure out the best possible result is not that important. It's sufficient to start from one corner and simply add until all polygons have been dissolved. Also there could be a situation where the polygon has a larger count (110 for example) than expected. In such a case it would be left single - as it is.

So any ideas on the simplest approach in doing this? I expect some kind of loop function in needed. Not very familiar yet with those...

Thanks for any advice!

Attached is an example shape file to play with...


15 replies

Userlevel 4
Badge +13

tb-fm-d.fmw @miikamakela Your sample data is simple enough that no looping was required in my workspace which dissolves by the common _edge_id. I think that you will need a TopologyBuilder and a FeatureMerger or InlineQuerier in your solution whether or not looping is needed.

Badge +1

tb-fm-d.fmw @miikamakela Your sample data is simple enough that no looping was required in my workspace which dissolves by the common _edge_id. I think that you will need a TopologyBuilder and a FeatureMerger or InlineQuerier in your solution whether or not looping is needed.

Thanks @DanAtSafe for your fantastic solution! I have played with it a bit today and tried to understand it. Most importantly, it indeed seems to do exactly what I need. Very much appreciated!

 

 

Badge +1

tb-fm-d.fmw @miikamakela Your sample data is simple enough that no looping was required in my workspace which dissolves by the common _edge_id. I think that you will need a TopologyBuilder and a FeatureMerger or InlineQuerier in your solution whether or not looping is needed.

I played with this a bit more. Noticed that it does not output all features if selected value is small, like 30 or 50. I need to figure out how it can be set to output the delta also. Should not be too hard...

 

 

@miikamakela, I want to give this problem a try using genetic algorithm. Can you please let me know how to read the data from shp files?

Badge +1

@miikamakela, I want to give this problem a try using genetic algorithm. Can you please let me know how to read the data from shp files?

Hi, the .shp file (shape) is a standard GIS data format by esri. It can be read by almost any GIS software - including of course FME.

 

 

Badge +3

you can solve this more generically by querying the powerset of the id's. Then test the polygon against these subsets and see if they form a contiguous area.

It will create all solutions, so some may overlap. But this posted question does not provide a criterium for that.

Badge +3
Thanks @DanAtSafe for your fantastic solution! I have played with it a bit today and tried to understand it. Most importantly, it indeed seems to do exactly what I need. Very much appreciated!

 

 

Hi @danatsafe​, I have the same problem and was hoping you may be able to share the workbench that you did above with me. I know it's been a long time but I would very much appreciate it.

Thanks

B

Userlevel 1
Badge +11
Thanks @DanAtSafe for your fantastic solution! I have played with it a bit today and tried to understand it. Most importantly, it indeed seems to do exactly what I need. Very much appreciated!

 

 

Hi @bjudes The original workspace has been restored and I'm also attaching here a version updated to FME 2020.1.1.0

Badge +3
Thanks @DanAtSafe for your fantastic solution! I have played with it a bit today and tried to understand it. Most importantly, it indeed seems to do exactly what I need. Very much appreciated!

 

 

Hi @danatsafe​ 

Thanks so much for this, I really appreciate it. I want to take this a step further and am wondering if there is a way that I could merge multiple polygons until a certain value is reached. Once it is reach we move onto the next set of polygons and so on and so forth until we have no polygons left. For example we have 100 polygons, and the maximum value of the merged polygon can be 30m2. Say it takes 30 contiguous polygons to get to 30m2 (or as close as we can get it). These are now merged and we move onto the remaining polygons until they reach 30m2, however many or few that may take. I hope this makes sense and I appreciate your help.

 

Kind regards

B

Badge +1
Thanks @DanAtSafe for your fantastic solution! I have played with it a bit today and tried to understand it. Most importantly, it indeed seems to do exactly what I need. Very much appreciated!

 

 

Hi @bjudes​, it seems I have originally replied to the wrong person. The one who developed this wb is @daniseminger but it seems the account is no longer active?

Userlevel 4
Thanks @DanAtSafe for your fantastic solution! I have played with it a bit today and tried to understand it. Most importantly, it indeed seems to do exactly what I need. Very much appreciated!

 

 

I believe @danatsafe​ is indeed Dan Iseminger.

Badge +1
Thanks @DanAtSafe for your fantastic solution! I have played with it a bit today and tried to understand it. Most importantly, it indeed seems to do exactly what I need. Very much appreciated!

 

 

Great, then all is well.. :-D

Badge +1

Hi all, I am revisiting this problem - Attached is a new sample dataset and the Workbench created by Dan a few years ago.

 

As final output I would like to have dissolved polygons providing only one solution. Currently it seems it outputs all dissolve options. With this new sample dataset a count target could be 200 per dissolved area.

 

What I want to achieve is dissolve the polygons with small counts to something else - if we can get close to 200 it's good but not critical. Reducing the amount of polygons is the key target.

 

Thanks for any help!

Userlevel 1
Badge +11

Hi all, I am revisiting this problem - Attached is a new sample dataset and the Workbench created by Dan a few years ago.

 

As final output I would like to have dissolved polygons providing only one solution. Currently it seems it outputs all dissolve options. With this new sample dataset a count target could be 200 per dissolved area.

 

What I want to achieve is dissolve the polygons with small counts to something else - if we can get close to 200 it's good but not critical. Reducing the amount of polygons is the key target.

 

Thanks for any help!

Hi @miikamakela​ Do you want 200 polygons per dissolved area? That's very difficult. See @jdh​ 's answer at https://community.safe.com/s/question/0D54Q000080hKMKSA2/joining-polygons-together-until-an-attribute-range-is-satisfied

Badge +1

Hi @miikamakela​ Do you want 200 polygons per dissolved area? That's very difficult. See @jdh​ 's answer at https://community.safe.com/s/question/0D54Q000080hKMKSA2/joining-polygons-together-until-an-attribute-range-is-satisfied

Hi @danatsafe​! Sorry I was unclear with my explanation. I have a new sample dataset (attached). I want to dissolve all polygons which have an attribute value of 10 or less (low limit) to their neighbors (and sum the values). The new features should not have a summed value greater than 220 (high limit).

 

The workbench you created some years ago (above in this thread) works well, but I was not able to figure how to remove the duplication. Now it seems to produce all possible dissolve combinations. I just want one "bin packing" solution covering the entire extent. It does not have to be the most optimized - as long as the result has less polygons than in the original. My highest interest is to get rid of polygons which have a very low value and dissolve them in to their neighbors.

 

Hope this is clear!

 

image

Reply