Merging Polygons with the Dissolver Transformer

Liz Sanderson
Liz Sanderson
  • Updated

Introduction

A common GIS operation is to merge (or dissolve) polygons; for example, two (or more) polygons have their shared boundary removed, leaving a single polygon.

For example, I might have a dataset of polygons representing Canada's provinces. I want to dissolve them into a single polygon representing Canada as a whole.

The transformer used to perform this operation in FME is called the Dissolver. Often polygons need to be dissolved according to some attribute value, and the "Group-By" parameter in the Dissolver allows this to happen.

Note that polygons do not have to have exact boundaries to be dissolved. It is equally possible to dissolve polygons whose boundary overlaps; either those whose boundaries naturally overlap or those whose boundaries are meant to coincide but are badly defined.

Video

 

This video was recorded using FME 2016. The interface may look different, but the concepts are still the same

Source Data

The source datasets for these examples are an Excel spreadsheet of election results and a GML-formatted polygon dataset representing election boundaries.

This example will merge the election results onto the election boundaries so that neighboring boundaries won by the same candidate/party can be dissolved together.

Step-by-step Instructions

1. Add GML Reader

Start FME Workbench and begin with an empty canvas. Select Readers > Add Reader from the menubar.

GMLReader.png

Set the data format to OGC GML (Geography Markup Language). Select the ElectionBoundaries.gml file as the source dataset, which is available to download from the Files section of this article. When prompted, select only the VotingDivisions feature type (layer) to add to the workspace.

GMLFT.png

2. Add Excel Reader

Once more, select Readers > Add Reader from the menubar. This time, set the format to Microsoft Excel and select the ElectionResults.xls Excel file as the source. 

ExcelReader.png

When prompted, select only the PartyResults sheet to add to the workspace.

ExcelFT.png

3. Merge Features

Add a FeatureMerger transformer to the workspace. Connect the VotingDivisions feature type to the Requestor port and the PartyResults feature type to the Supplier port:

ConnectFeatureMerger_2.gif

Open the parameters dialog and select the Division attribute under the Requestor and Supplier Join attributes:

FJ.png

This will merge all attributes from the PartyResults (Supplier) table onto the VotingDivision (Requestor) polygons where the Division attribute matches.

4. Color Each Party Differently

We'll want to inspect the Dissolver output so each party's wins are colored differently; add a FeatureColorSetter transformer connected to the FeatureMerger:Merged port.

FTSSS.png

Open the parameters dialog. Set the Color Scheme to Random and set the Randomize Based On parameter to "Attributes". Select the Winner attribute (which was copied from the PartyResults table) as the attribute to randomize by:

FCS.png

This will color each polygon the same color as the party that won it.

5. Inspect Output

Attach an Inspector transformer and run the workspace. In Visual Preview, you should find that each polygon is colored according to the winner, but adjacent polygons of the same color are not (yet) merged:

NotMerged.png

6. Dissolve Polygons

Now, add a Dissolver transformer into the workspace, before the FeatureColorSetter:

gisdissolve5.png

Open the Dissolver parameters dialog. Under the Group-By parameter, select the Winner attribute. This will ensure that polygons are merged only when the value of the Winner attribute matches.

DissolverParameters.png

Under the Attributes to Sum parameter, select the attributes Party1, Party2, and Party3. These attributes represent the number of votes per area, per party. By selecting them here, the votes from each dissolved polygon will be combined.

Dissolver.png

Re-run the workspace. The result will now look like this:

EndOutput.gif

Notice that adjoining areas - where they were won by the same party - have been dissolved together. Also, notice that the number of votes for each party in each dissolved area has been added together to provide a new value for the single dissolved polygon.

Data Attribution

The data used here originates from open data made available by the City of Vancouver, British Columbia. It contains information licensed under the Open Government License - Vancouver.

Was this article helpful?

We're sorry to hear that.

Please tell us why.

As of January 14th, 2026, comments on knowledge base articles have been closed. To make sure questions don’t get missed and to enable more community support, we’ve moved discussions to the FME Community. If you have a question or a comment about this article, please create a new post or create a support ticket.