Solved

Converting polygon into lines

  • 26 June 2020
  • 7 replies
  • 333 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.

icon

Best answer by david_r 26 June 2020, 14:46

View original

7 replies

Userlevel 1
Badge +21
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
Userlevel 4

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.

Badge +2

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.

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.

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.

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.

Userlevel 1
Badge +21

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

Reply