HOW TO

Determine if a polygon intersects itself

Last Published: April 25, 2020

Summary

MapObjects can work with self-intersecting polygons, such as a figure-8; however, the MapObjects 2.x geometric algebra methods (Intersect, Union, Xor, Difference) will fail if passed a self-intersecting polygon. Also, SDE layers may not store or work with self-intersecting polygons. Because of these limitations, it may be helpful to know whether a polygon is self-intersecting or not.

Procedure

To determine if a polygon is self-intersecting using MapObjects, simply intersect the polygon with its own Extent. If the result is Nothing (nil), then the polygon is self-intersecting. The Visual Basic code below demonstrates this technique.


Code:
Option Explicit
Dim iPoly As MapObjects2.Polygon

Private Sub Map1_AfterTrackingLayerDraw(ByVal hDC As stdole.OLE_HANDLE)

Dim sym As New MapObjects2.Symbol
sym.SymbolType = moFillSymbol
sym.Color = moRed

If Not iPoly Is Nothing Then
Map1.DrawShape iPoly, sym
End If

End Sub

Private Sub Map1_MouseDown(Button As Integer, Shift As Integer,
X As Single, Y As Single)

Dim poly As MapObjects2.Polygon
Dim rect As MapObjects2.Rectangle

Set poly = Map1.TrackPolygon
Set rect = poly.Extent
Set iPoly = poly.Intersect(rect)
If Not iPoly Is Nothing Then
Map1.Refresh
Else
MsgBox "Poly is not valid."
Map1.Refresh
End If

End Sub

Article ID:000004536

Software:
  • Legacy Products

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options

Discover more on this topic