Question

How to generate straight center line for a polygon?

  • 11 October 2019
  • 5 replies
  • 86 views

Badge

This is my input geometry

This is my desired output: I want to generate the red line.

CenterlineReplacer does not do a good job btw.

 


5 replies

Userlevel 2
Badge +16

Maybe not the best, but I would try this:

Use the BoundingBoxReplacer to create a bounding box.

Then use the GeometryCoercer on both area and bounding box, to create 2 closed lines.

Then use the Intersector (Node output) to find the 2 intersection points.

Connect the 2 points to create the required straight line (2DPointConnector).

Hope this helps.

Badge +21

What about using centerpointreplacer and draw a line between top centerpoint and bottompoint?

Userlevel 4
Badge +25

Which version of FME are you using? Because the CentreLineReplacer has received some updates and fixes in recent versions. I tried this in 2019 using an approximation of your geometry, and it worked fine:

See attached workspace.

Badge

Which version of FME are you using? Because the CentreLineReplacer has received some updates and fixes in recent versions. I tried this in 2019 using an approximation of your geometry, and it worked fine:

See attached workspace.

How come the line looks so weird? It is not straight and doesn't touch the edges.

Userlevel 4
Badge +25

How come the line looks so weird? It is not straight and doesn't touch the edges.

Try the medial line mode. That should make it straight. Then you could do something like the Intersector, AnchoredSnapper, or LineExender to extend it to the full extents of the polygon (I've no idea why it doesn't reach that far).

Reply