Skip to main content
Solved

Converting polygon into lines


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.

View original
Did this help you find an answer to your question?

7 replies

ebygomm
Influencer
Forum|alt.badge.img+32
  • Influencer
  • 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
  • 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

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.


david_r wrote:

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.


jlbaker2779 wrote:

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.


ebygomm wrote:
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+32
  • Influencer
  • June 26, 2020
thewindgone wrote:

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


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