Skip to main content
Solved

How can I count the number of concave interior angles in a polygon?

  • February 23, 2022
  • 7 replies
  • 91 views

I would like some advice on setting up a workbench that could retrieve the number of interior angles in a polygon that are classed as concave (i.e. >180 degrees).

 

So far I have the following:

  1. run my polygon featureclass through the 'convexity filter' to obtain only concave polygons.
  2. I then use the 'Orientor' to assign the right hand rule before passing it through the 'VertexAngleCalculator'.
  3. I then use a tester to filter those angle that are negative (i.e. concave).
  4. Use 'statistics calculator grouped by original polygon UID to get the total count of features.
  5. merge these attributes with the original feature class.

 

This works fine as long as the first/last vertex in the polygon is not a concave angle. This is because the 'VertexAngleCalculator' returns a value of '0' for the start/end vertex - and therefore cannot be classified.

 

Unless there is a simpler way to obtain all interior angles for each polygon, my thoughts would be to re-run the process a second time, first shifting the order of vertices by 1 index place. Then removing all features from both passes with a angle attribute of 0, and removing duplicates from the first pass that have the same geometry and angle attribute as in the second pass. Unfortunately I have no idea how to do this in FME.

 

Any help would be greatly appreciated!

Best answer by geomancer

You can calculate the angle of the start/end vertex from all other angles, as the sum of all interior angles of the polygon is 

(NumberOfVertices − 2) × 180

Note that the VertexCounter counts both the start and the end vertex, so you will have to subtract 3 from the result of this transformer.

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

7 replies

geomancer
Evangelist
Forum|alt.badge.img+47
  • Evangelist
  • Best Answer
  • February 23, 2022

You can calculate the angle of the start/end vertex from all other angles, as the sum of all interior angles of the polygon is 

(NumberOfVertices − 2) × 180

Note that the VertexCounter counts both the start and the end vertex, so you will have to subtract 3 from the result of this transformer.


  • Author
  • February 23, 2022
geomancer wrote:

You can calculate the angle of the start/end vertex from all other angles, as the sum of all interior angles of the polygon is 

(NumberOfVertices − 2) × 180

Note that the VertexCounter counts both the start and the end vertex, so you will have to subtract 3 from the result of this transformer.

Thanks geomancer, a much simpler solution!


geomancer
Evangelist
Forum|alt.badge.img+47
  • Evangelist
  • February 23, 2022

You're welcome!

Meanwhile, I have been thinking of a completely different approach.

Calculate the convex hull of the polygon, perform an AreaOnAreaOverlayer or a Clipper, and work with the polygon(s) that are not part of the original polygon. If such a polygon is convex, its number of vertices minus 2 (or 3, using the VertexCounter, see above) gives the number of concave angles in the adjacent part of the original polygon.

There is a caveat though, as the resulting polygons may be concave themselves.

This can probably be solved (by looping, I guess), but I have not gotten that far yet.


Forum|alt.badge.img+2
  • February 23, 2022

@callumt​ You have the best solution from @geomancer​ . But I was pretty sure the TopologyBuilder also returns the angles so I played around with that, and it does. Attached is an option using TopologyBuilder (FME 2021.2)


  • Author
  • February 24, 2022
markatsafe wrote:

@callumt​ You have the best solution from @geomancer​ . But I was pretty sure the TopologyBuilder also returns the angles so I played around with that, and it does. Attached is an option using TopologyBuilder (FME 2021.2)

Thanks Mark, I hadn't used the Topology builder yet so its good to know of all available solutions.


geomancer
Evangelist
Forum|alt.badge.img+47
  • Evangelist
  • March 17, 2022

You may also be interested in the PolylineAnalyzer from FME Hub (which, despite its name, also processes polygons).

It gives the inner angles over the AngleBetweenLines port (when you first set the orientation to 'Right Hand Rule' with the Orientor), and appears not to have the problem of returning a value of '0' for the start/end vertex.


Forum|alt.badge.img+5
  • April 5, 2022

Besides the plethora of other excellent answers, I've now fixed the issue in VertexAngleCalculator causing the shared start/end vertex on area features to have a zero angle.


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