Skip to main content
I am having a bit of a frustrating experience with the CenterlineReplacer that I am hoping someone can help with.

 

 

Desired Outcome: 

 

 

Centerline the entire length of the polygon "tiles." The length is a user-parameter and will determin the length of the line. By having the centerline "clipped" inside the polygon I am losing the correct length.

 

 

Background:

 

 

I have a number of 'tiles' (ie polygons) that I want to essentially spit in half and keep the centerline. Sounds like a job for the CenterlineReplacer.

 

 

However, whenever I run the transformer I get 3 undesirable results.
  • First, it does not split the entire lengh. It essentially starts partway down the middle.
  • Second, one of the centerlines always "snaps" to the corner of one polygon. 
  • Third, the line directions vary. I would like all line directions in the same orientation. Note, I have a process that fixes this but it's more of a hack.
Here is a screenshot of the undesireable output:

 

 

 

Does anyone have any better ideas/suggestions on how to split each polygon 100% down the middle? Again, the final output is the centerline itself.

 

 

Regards,

 

 

 

Matthew Brucker
Hi Matthew,

 

 

If every polygon is always a rectangle (having just 4 edges), a possible way is as the following. Assuming every rectangular polygon has unique ID as its attribute:

 

1) Chopper: Decompose every rectangle into their edge lines.

 

Mode: By Vertex

 

Maximum Vertices: 2

 

2) LengthCalculator: Calculate the length of every edge.

 

3) Sorter: Sort the edges  by ID and length ascending.

 

4) Sampler: Select first 2 edges (i.e. shorter edges of rectangle) for each ID.

 

Group By: ID

 

Sampling Type: First N Features

 

Sampling Amount: 2

 

5) CenterPointReplacer: Transform selected edges into their center points.

 

6) PointConnector: Connect each 2 points to create required lines.

 

Connection Break Attributes: ID

 

 

Be aware that  this way may not work when a polygon is not clean (e.g. having duplicate vertices etc.). In such a case, consider cleaning up polygons before the processing.

 

 

Another approach. If input polygons are clean rectangles, this way may also work.

 

1) CenterLineReplacer: Create shorter center lines (Mode: Medial Axis).

 

2) Deaggregator: De-aggregate the line, since the CenterLineReplacer always creates aggregate feature.

 

3) Extender: Stretch the lines.

 

4) Clipper: Clip stretched lines by the original rectangles (Group By: ID).

 

 

Result:

 

 

 

Takashi
Hey Takashi,

 

 

The second approach is basically what I did/am doing. I find that with FME I usually come up with some pretty elegant solutions. At this point I have a viable solution so I'm not going to push this one too much. 

 

 

I did struggle with the aggregate portion of the CenterLineReplacer for a week before I stumbled on that. I wish that was a little better documented but FME is like the wild west of GIS!

Reply