Skip to main content
Solved

Converting polygon into lines

  • June 26, 2020
  • 7 replies
  • 2406 views

I have searched some methods to convert polygon into lines on FME. But none of these could do it.

Firstly, I extract a closed polyline of a polygon with GeometryPartExtractor, and then try to decompose it with Chopper. But instead of four lines, the result is many of broken segments.

Secondly, I turn a polygon to a closed polyline with GeometryCoercer, and then try to decompose it to four lines. But the result is also many of broken segments with Chopper, or only one closed polyline with Intersector.

 

Why is that? Can anyone help me? Thank you so much.

Best answer by david_r

As long as the polygons are perfectly rectangular, you could use the BoundingBoxReplacer in mode "2D oriented bounding box" to get a simplified polygon with only 4 vertices based on the input geometry. The Chopper set to 2 vertices should then do the trick.

Alternatively, look into generalizing the polygon perimeter before using the Chopper, it might be that the polygon have a lot of unnecessary vertices on the straights.

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

7 replies

ebygomm
Influencer
Forum|alt.badge.img+44
  • Influencer
  • 3427 replies
  • June 26, 2020
After chopping to line segments you could use the custom transformer HorizontalAngleCalculator to calculate the angle of the line, then use a LineCombiner and combine on the angle attribute to join the line segments

david_r
Celebrity
  • 8392 replies
  • Best Answer
  • June 26, 2020

As long as the polygons are perfectly rectangular, you could use the BoundingBoxReplacer in mode "2D oriented bounding box" to get a simplified polygon with only 4 vertices based on the input geometry. The Chopper set to 2 vertices should then do the trick.

Alternatively, look into generalizing the polygon perimeter before using the Chopper, it might be that the polygon have a lot of unnecessary vertices on the straights.


Forum|alt.badge.img+2
  • 194 replies
  • June 26, 2020

Is your maximum vertices in the chopper set to 2? Also, you shouldn't need the extractor since the Chopper will change the polygons into split lines automatically.


  • Author
  • 17 replies
  • June 26, 2020

As long as the polygons are perfectly rectangular, you could use the BoundingBoxReplacer in mode "2D oriented bounding box" to get a simplified polygon with only 4 vertices based on the input geometry. The Chopper set to 2 vertices should then do the trick.

Alternatively, look into generalizing the polygon perimeter before using the Chopper, it might be that the polygon have a lot of unnecessary vertices on the straights.

Thank you so much! It does really work.


  • Author
  • 17 replies
  • June 26, 2020

Is your maximum vertices in the chopper set to 2? Also, you shouldn't need the extractor since the Chopper will change the polygons into split lines automatically.

Thank you. The maximum vertices in the chopper is set to 2. And I have used david_r 's method to do it.


  • Author
  • 17 replies
  • June 26, 2020
After chopping to line segments you could use the custom transformer HorizontalAngleCalculator to calculate the angle of the line, then use a LineCombiner and combine on the angle attribute to join the line segments

Thank you for your reply. And I think david_r 's method is more simpler.


ebygomm
Influencer
Forum|alt.badge.img+44
  • Influencer
  • 3427 replies
  • June 26, 2020

Thank you for your reply. And I think david_r 's method is more simpler.

Yes, if your shapes are always perfect rectangles it's definitely more straightforward/efficient