Skip to main content

I have a test Shapefile with 19 roads/segments. I want to merge all segments that are shorter than 200m with the shortest adjacent segment, and use the attributes of the adjacent segment for the new road segment. I've got most of the logic working, but can't get it to loop until there are no more segments less than 200m in length.

 

The attached workspace shows one iteration going from 19 records to 18 records.

 

Any pointers as to where I'm going wrong appreciated!

Hi @geographix​,

The filter_adjacent SpatialFilter is looking for a touching line, but you don't have any adjacent touching lines shorter than 200m.

It seems that you are trying to simplify dual carriageway lines into a single line. If so, I would recommend trying the FME Hub transformer FuzzyParallelLineFinder, then using its match ids to join adjacent lines. This did a pretty good job identifying the dual carriageway lines in your sample dataset.


Thanks @daveatsafe​  for the detailed response. It's always good to find another transformer!

 

The aim of the workflow is to keep merging short segments until there are none left. What I can't get to work is looping through a blocking transformer where the output of one iteration becomes the input of the next iteration until all features are processed.

 

The issue you found with dual carriageways is OK - where there isn't an adjacent segment, the segment will be marked as IS_PROCESSED and excluded from further processing. When the count of IS_PROCESSED segments matches the total number of segments, the loop should exit. I expect to find some short segments that couldn't be combined.

 

It is the process of creating Linked Blocking Transformers that I find confusing.

 

https://community.safe.com/s/question/0D54Q000080hdrkSAA/how-to-expose-attribute-iteration-count-in-a-loop and https://community.safe.com/s/question/0D54Q0000849mBISAY/how-make-loop-with-blocking-transformers-in-fmx are providing some tips, but I can't put the pieces together.


Last time I did this with pipes, I duplicated 5 or 6 feature mergers and it did the job for the dataset I had. Not as clean as looping, but it was simple.

Basically, for every line shorter than 200m, add/derive an attribute of the ID of a longer line it should merge into (could spatially be the longest line it touches, longest line within 50m etc). For every line longer than 200m, its target ID to merge with is its own ID (this stops the loop). Then with feature mergers, the Requestors are the short lines, Suppliers are ALL lines. Merge where the requestor's target ID to merge to = the Supplier's ID. Many short lines will merge with other short lines because that's all they touch initially, so after the merge, make the new target ID to merge into be what the Supplier's ID was. Then, repeat.

At each step each line will merge with another longer line, and take that longer line's ID of another longer line to merge with. With enough steps everything will hit the threshold, and you can combine the line geometries.


Last time I did this with pipes, I duplicated 5 or 6 feature mergers and it did the job for the dataset I had. Not as clean as looping, but it was simple.

Basically, for every line shorter than 200m, add/derive an attribute of the ID of a longer line it should merge into (could spatially be the longest line it touches, longest line within 50m etc). For every line longer than 200m, its target ID to merge with is its own ID (this stops the loop). Then with feature mergers, the Requestors are the short lines, Suppliers are ALL lines. Merge where the requestor's target ID to merge to = the Supplier's ID. Many short lines will merge with other short lines because that's all they touch initially, so after the merge, make the new target ID to merge into be what the Supplier's ID was. Then, repeat.

At each step each line will merge with another longer line, and take that longer line's ID of another longer line to merge with. With enough steps everything will hit the threshold, and you can combine the line geometries.

Thanks @ctredinnick​ - I've not used FeatureMerger that much until attempting to reproduce your solution. It has a neat trick to stop the loop. Using multiple FeatureMergers does feel 'dirty', and that a loop would be the cleanest solution to understand and modify. I've got a version that starts with the shortest segments, then moves up to 100m, then to 200m but it seems to contradict the principles of Don't Repeat Yourself.

 

This is the workflow to do one iteration. Can anyone propose a Looping Block Transformer to make it work in a loop until there are no more short segments?combine shortest road with shortest adjacent road v2


Reply