Question

Is there a way to merge/dissolve the target polygons into their smallest neighbours?

  • 8 August 2018
  • 8 replies
  • 17 views

Hi, I've got a GDB file which contains over 1 million polygons and I'd like to merge/dissolve every polygon under 3000 suqare meters into their smallest neighbours. I've tried to use eliminate tool in ArcGIS toolbox, it will only meger to the biggest polygons, not exactly what I want. Then I got it working by using Spatial Join and other tools, but the process took too much time, about 5 hours.

So I'm hoping FME got some transformers can make this happen, at least some transformer like the tools in ArcGIS.

Here's an example below, I'd like to merge the selected polygon into the one with 795.67m2 rather than the one with 9798080.13m2.

@takashi


8 replies

Userlevel 2
Badge +17

Hi @bobo, my idea is, create topology edges from the polygon boundaries, remove edges between faces to be merged, and rebuild polygons from remaining edges.

I think the attached workflow should work theoretically if the polygon boundaries are topologically clean - i.e. no gaps / no overlaps between adjacent polygons in the full precision.

dissolve-polygons-with-smallest-neighbor.fmwt (FME 2018.1.0.0)

Userlevel 2
Badge +17

Hi @bobo, my idea is, create topology edges from the polygon boundaries, remove edges between faces to be merged, and rebuild polygons from remaining edges.

I think the attached workflow should work theoretically if the polygon boundaries are topologically clean - i.e. no gaps / no overlaps between adjacent polygons in the full precision.

dissolve-polygons-with-smallest-neighbor.fmwt (FME 2018.1.0.0) 

Most transformers in my previous solution were able to be replaced with an InlineQuerier.

 

0684Q00000ArMZiQAN.png

 

SQL Statement:

 

with
"candidates" (_edge_id, _this_id, neighbor_area) as (
    select
        a._edge_id,
        a._this_id,
        b._area as neighbor_area
    from (
        select
            _edge_id,
            _left_face as _this_id,
            _right_face as _neighbor_id
        from "Edge" where _left_face <> 0 and _right_face <> 0
        union all
        select
            _edge_id,
            _right_face as _this_id,
            _left_face as _neighbor_id
        from "Edge" where _left_face <> 0 and _right_face <> 0
    ) as a
    inner join "Face" as b on b._face_id = a._neighbor_id
    where a._this_id in (select _face_id from "Face" where _area < $(MAX_AREA))
)
select * from "Edge"
where _edge_id not in (
    select distinct _edge_id
    from "candidates" as a
    inner join (
        select
            _this_id,
            min(neighbor_area) as min_neighbor_area
        from "candidates" group by _this_id
    ) as b on b._this_id = a._this_id and b.min_neighbor_area = a.neighbor_area
)

 

Hi @bobo, my idea is, create topology edges from the polygon boundaries, remove edges between faces to be merged, and rebuild polygons from remaining edges.

I think the attached workflow should work theoretically if the polygon boundaries are topologically clean - i.e. no gaps / no overlaps between adjacent polygons in the full precision.

dissolve-polygons-with-smallest-neighbor.fmwt (FME 2018.1.0.0)

Thank you very much, I just had the fmwt file working, it seems that the connection between Tester_2 Passed and Attributemanager_4 is not necessary. After removing it I got the result I wanted.

 

Futher more, is there any way to attach or keep other original attributes like GRADE onto the polygons? Only attributea from polygons be merged to need to be preserved. I'm thinking about converting polygons with area over 3000m2 into points, then giving their attributes to merged polygons.

 

 

Userlevel 2
Badge +17

Hi @bobo, my idea is, create topology edges from the polygon boundaries, remove edges between faces to be merged, and rebuild polygons from remaining edges.

I think the attached workflow should work theoretically if the polygon boundaries are topologically clean - i.e. no gaps / no overlaps between adjacent polygons in the full precision.

dissolve-polygons-with-smallest-neighbor.fmwt (FME 2018.1.0.0)

You already have a solution. Use the CenterPointReplacer (Mode: Inside Point) to transform the original polygons larger than 3000 to their inside points, then filter the merged polygons by those points with the SpatialFilter (Spatial Predicates to Test: "Filter is Within Candidate", Merge Attributes: <checked>, Accumulation Mode: Merge Filter).

 

 

Hi @bobo, my idea is, create topology edges from the polygon boundaries, remove edges between faces to be merged, and rebuild polygons from remaining edges.

I think the attached workflow should work theoretically if the polygon boundaries are topologically clean - i.e. no gaps / no overlaps between adjacent polygons in the full precision.

dissolve-polygons-with-smallest-neighbor.fmwt (FME 2018.1.0.0)

Thank you again, got it working. But some transformers have parallel processing parameter, why can't I set it to extreme or other options? Only No Parallelism will work.
Userlevel 2
Badge +17

Hi @bobo, my idea is, create topology edges from the polygon boundaries, remove edges between faces to be merged, and rebuild polygons from remaining edges.

I think the attached workflow should work theoretically if the polygon boundaries are topologically clean - i.e. no gaps / no overlaps between adjacent polygons in the full precision.

dissolve-polygons-with-smallest-neighbor.fmwt (FME 2018.1.0.0)

See here to learn About Parallel Processing.

 

In short, Parallel Processing can be effective only if the features can be grouped. I don't think Parallel Processing is available in this case.

 

 

Badge

Hi @bobo, my idea is, create topology edges from the polygon boundaries, remove edges between faces to be merged, and rebuild polygons from remaining edges.

I think the attached workflow should work theoretically if the polygon boundaries are topologically clean - i.e. no gaps / no overlaps between adjacent polygons in the full precision.

dissolve-polygons-with-smallest-neighbor.fmwt (FME 2018.1.0.0)

Hi, this is a very useful solution! Thank you!

@takashi Is there a possibility to keep the attributes of the polygons without spatial relator but directly in the inline querier?

Userlevel 2
Badge +17

Hi @bobo, my idea is, create topology edges from the polygon boundaries, remove edges between faces to be merged, and rebuild polygons from remaining edges.

I think the attached workflow should work theoretically if the polygon boundaries are topologically clean - i.e. no gaps / no overlaps between adjacent polygons in the full precision.

dissolve-polygons-with-smallest-neighbor.fmwt (FME 2018.1.0.0)

Hi @oiram, a possible way is:

  1. Use the AreaCalculator to calculate the area of original polygons.
  2. Transform each of them into a point within the original polygon using the CenterPointReplacer (Mode: Any Inside Point). The resulting points will have all the attributes from the original polygons.
  3. You can then merge the attributes of the points to the resulting polygons from the AreaBuilder as a list attribute with the SpatialRelater (Requestor: original polygons, Supplier: inside points).
  4. The resulting polygon should have one or more points and the list stores the attributes from one or more corresponding original polygons. If you need the the attributes from the largest one in the original polygons, use the list by area (calculated at first) descending with the ListSorter then extract the first element of the list (index = 0) with the ListIndexer.

Hope this helps.

Reply