Skip to main content
Question

How to generate straight center line for a polygon?

  • October 11, 2019
  • 5 replies
  • 307 views

dataninja
Forum|alt.badge.img

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

erik_jan
Contributor
Forum|alt.badge.img+17
  • Contributor
  • October 11, 2019

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.


sigtill
Supporter
Forum|alt.badge.img+24
  • Supporter
  • October 11, 2019

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


mark2atsafe
Safer
Forum|alt.badge.img+44
  • Safer
  • October 16, 2019

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.


dataninja
Forum|alt.badge.img
  • Author
  • October 22, 2019
mark2atsafe wrote:

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.


mark2atsafe
Safer
Forum|alt.badge.img+44
  • Safer
  • October 22, 2019
dataninja wrote:

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


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings