Skip to main content

The highlighted Polygons should form a larger polygon with the same attributes. Both have different IDs, so after merging only one should be retained. The same transformation needs to occur for other polygons in the screenshot also. Usage of Dissolver and FeatureMerger transformers has not yielded results. I hope some light can be shed on the right approach to take here.

Hi @sandexter​ , looks like the vertical and the horizontal straight lines shown in your screenshot are boundaries of rectangular areas something like tiles. If so, are their x-coordinate (for vertical lines) and y-coordinate (for horizontal lines) known? Or, do the polygons have an attribute that stores ID of the parent "tile" to which each polygon belongs? 


@sandexter​ Dissolver should work in this case if you have areas that touch at the tile boundaries. You might have to use Snapper to make sure the boundary points do touch. Are you able to attach a small sample dataset?


Hi @sandexter​ , looks like the vertical and the horizontal straight lines shown in your screenshot are boundaries of rectangular areas something like tiles. If so, are their x-coordinate (for vertical lines) and y-coordinate (for horizontal lines) known? Or, do the polygons have an attribute that stores ID of the parent "tile" to which each polygon belongs? 

@Takashi Iijima​ Yes an attribute stores the tile ID for each feature. The highlighted polygons have different tile IDs but the tile IDs are sequential, (tile ID 10 for the one above and tile ID 11 for the one below). No, the coordinates aren't explicitly known for the lines.


As @Mark Stoakes​ says, the Dissolver should do the trick. You say it has not yielded results, can you show us how you have set it up?


Hi @sandexter​ , looks like the vertical and the horizontal straight lines shown in your screenshot are boundaries of rectangular areas something like tiles. If so, are their x-coordinate (for vertical lines) and y-coordinate (for horizontal lines) known? Or, do the polygons have an attribute that stores ID of the parent "tile" to which each polygon belongs? 

I think the following procedure might help you.

Create desired polygons:

  1. Dissolve the polygons grouping by tile ID to create tile polygons.
  2. Use the GeometryCoercer to convert all the tile polygons and the original polygons into their boundary lines.
  3. Send all the boundary lines to a LineOnLineOverlayer. Here, overlap count of a resulting line should be 4 3
  4. Use the Tester to filter out the lines whose overlap count is 4 3 /edited] - i.e. boundaries between two tiles.
  5. Send the remnant lines to an AreaBuilder to create polygons, which would be your desired ones.

 

Restore attributes of the original polygons:

  1. In another data flow, use the CenterPointReplacer (Mode: Any Inside Point) to transform the original polygons with their inside points.
  2. Use the SpatialFilter to merge the attributes from the inside point to the resulting polygons created by the procedure above.

As @Mark Stoakes​ says, the Dissolver should do the trick. You say it has not yielded results, can you show us how you have set it up?

If the polygons to be dissolved have the same ID, it would be easy to dissolve them with the Dissolver, by setting the ID attribute to the Group By parameter. However, in this case, the IDs of polygons are different each other.

I thinks it's the point of the question.


I think the following procedure might help you.

Create desired polygons:

  1. Dissolve the polygons grouping by tile ID to create tile polygons.
  2. Use the GeometryCoercer to convert all the tile polygons and the original polygons into their boundary lines.
  3. Send all the boundary lines to a LineOnLineOverlayer. Here, overlap count of a resulting line should be 4 3 [edited] if it is a boundary between two tiles, 2 otherwise.
  4. Use the Tester to filter out the lines whose overlap count is 4 3 [edited] - i.e. boundaries between two tiles.
  5. Send the remnant lines to an AreaBuilder to create polygons, which would be your desired ones.

 

Restore attributes of the original polygons:

  1. In another data flow, use the CenterPointReplacer (Mode: Any Inside Point) to transform the original polygons with their inside points.
  2. Use the SpatialFilter to merge the attributes from the inside point to the resulting polygons created by the procedure above.

@Takashi Iijima​ Thank you for the detailed response. I was able to repeat the steps 1 and 2. However, in step 3, the overlap count for both tile boundaries is 2 and otherwise is either 1 or 2. How should i approach this?


If the polygons to be dissolved have the same ID, it would be easy to dissolve them with the Dissolver, by setting the ID attribute to the Group By parameter. However, in this case, the IDs of polygons are different each other.

I thinks it's the point of the question.

@Takashi Iijima​ You are correct


Hi @sandexter​ , looks like the vertical and the horizontal straight lines shown in your screenshot are boundaries of rectangular areas something like tiles. If so, are their x-coordinate (for vertical lines) and y-coordinate (for horizontal lines) known? Or, do the polygons have an attribute that stores ID of the parent "tile" to which each polygon belongs? 

I think theoretically the overlap count of the lines output from the LineOnLineOverlayer should be 4 (3 was wrong in my previous answer) if the line was on a tile boundary, 2 otherwise.

See also the attached workspace template (FME 2020.1.1.1) including a sample dataset.

merge-adjacent-polygons-example


Looks like nearly the same issue I am facing --> https://community.safe.com/s/question/0D54Q00008DrPoxSAF/aggregat-polygones-which-touch-or-intersect-each-other-on-the-basis-of-conditions?t=1603950884399

 

Maybe some projections can help you (e.g. the SpatialRelator with Lists).


I think the following procedure might help you.

Create desired polygons:

  1. Dissolve the polygons grouping by tile ID to create tile polygons.
  2. Use the GeometryCoercer to convert all the tile polygons and the original polygons into their boundary lines.
  3. Send all the boundary lines to a LineOnLineOverlayer. Here, overlap count of a resulting line should be 4 3 [edited] if it is a boundary between two tiles, 2 otherwise.
  4. Use the Tester to filter out the lines whose overlap count is 4 3 [edited] - i.e. boundaries between two tiles.
  5. Send the remnant lines to an AreaBuilder to create polygons, which would be your desired ones.

 

Restore attributes of the original polygons:

  1. In another data flow, use the CenterPointReplacer (Mode: Any Inside Point) to transform the original polygons with their inside points.
  2. Use the SpatialFilter to merge the attributes from the inside point to the resulting polygons created by the procedure above.

Okay, with this projection I was able to fix my problem (https://community.safe.com/s/question/0D54Q00008DrPoxSAF/aggregat-polygones-which-touch-or-intersect-each-other-on-the-basis-of-conditions?t=1603950884399)! Thank you takashi.

 

I will describe it in "my" thread in deep, so maybe it will help you sandexter too.


Reply