Skip to main content
1 of 4
sunt05
  • 4.5k
  • 24
  • 36

detect and fix invalid `Polygon`

I have a Polygon below

Polygon[{{2437.21,166.705},{2437.38,166.856},{2440.37,163.438},{2435.84,159.581},{2442.18,152.113},{2431.45,142.989},{2420.63,153.885},{2428.72,160.067},{2418.95,168.237},{2435.2,183.216},{2446.11,174.504},{2437.21,166.705}}] 

which visually looks good in the sense of shape:

enter image description here

However, this shape cannot be used for Region-related operations as it is "ill-defined" with an interior line:

enter image description here

whose zoom-in view is like this:

enter image description here

My question is:

How can I detect such "ill-defined" polygons and fix them?

sunt05
  • 4.5k
  • 24
  • 36