Skip to main content
Solved

Calculate polygons angles to horizon


yahyanar
Contributor
Forum|alt.badge.img+2

I have a lot of polygons that represent buildings and I want to rasterise them but before I do I need all the polygons to be parallel to the horizon. I need to create a tool that calculates the polygon angles and then use these angles to rotate the buildings accordingly. 

Best answer by DanAtSafe

Hi @yahyanar Try this

which uses the BoundingBoxReplacer to get the angle of the longest side.

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

10 replies

danilo_fme
Evangelist
Forum|alt.badge.img+44
  • Evangelist
  • August 6, 2024

Hi @yahyanar 

 

Please, could you send a dataset to test?


yahyanar
Contributor
Forum|alt.badge.img+2
  • Author
  • Contributor
  • August 6, 2024

Hi,

 

here I uploaded some buidlings which I want to calculate the dominant angles and use them to rotate the buildings to get them horizontal.

 

thanks in advance


DanAtSafe
Safer
Forum|alt.badge.img+18
  • Safer
  • Best Answer
  • August 9, 2024

Hi @yahyanar Try this

which uses the BoundingBoxReplacer to get the angle of the longest side.


yahyanar
Contributor
Forum|alt.badge.img+2
  • Author
  • Contributor
  • August 14, 2024

Hi @DanAtSafe,

 

Thank you very much for your support. I will try it and give you a feedback.

 

 


yahyanar
Contributor
Forum|alt.badge.img+2
  • Author
  • Contributor
  • August 14, 2024

Hi DanAtSafe,

 

I am using FME 2021.2 and it seems that BoundingBoxReplacer does not have Long Side Angle parameter. When I choose Replace with: 2D Oriented Bounding Box, I got only 2 options (see attached).

any suggestions?


DanAtSafe
Safer
Forum|alt.badge.img+18
  • Safer
  • August 15, 2024

Hi @yahyanar The azimuth was added to BoundingBoxReplacer in FME 2022.1

Here’s the work-around if you can’t upgrade:

 


yahyanar
Contributor
Forum|alt.badge.img+2
  • Author
  • Contributor
  • August 15, 2024

Hi @DanAtSafe,

 

Thank you very much. 

I have used HorizonAngleCalculator instead of AzimuthCalculator (HAC is upgrad version of AC). However, as you can see in the figure attached only one feature of the center points entered the process and finally, I got rejected. 


DanAtSafe
Safer
Forum|alt.badge.img+18
  • Safer
  • August 17, 2024

Hi @yahyanar Did you change the ExpressionEvaluator so that it calculates the angle to rotate with _angle instead of acAngle?  In your Navigator, go to Workspace Parameters/Translation and change “Rejected Feature Handling” to “Continue Translation”.  Then you’ll be able to see the reason why FeatureMerger_3 is rejecting features.


yahyanar
Contributor
Forum|alt.badge.img+2
  • Author
  • Contributor
  • August 17, 2024

Hi @DanAtSafe,

 

Yes I have changed the ExpressionEvaluator to _angle. Also, I have changed the workspace parameters and I got the results attached.

 


yahyanar
Contributor
Forum|alt.badge.img+2
  • Author
  • Contributor
  • August 19, 2024

Hi @DanAtSafe ,

 

I did some changes where I have added a “Sorter” and I “FeatureMerger” and now the script works probably. 

here is the result

 


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