Removes the specified ring, and all of the points that compose that ring, from the Polygon.
Namespace:
ESRI.ArcGISExplorer.GeometryAssembly: ESRI.ArcGISExplorer (in ESRI.ArcGISExplorer.dll) Version: 2.0.0.1500 (2.0.0.1500)
Syntax
C# |
---|
public void RemoveRing( int ringIndex ) |
Visual Basic (Declaration) |
---|
Public Sub RemoveRing ( _ ringIndex As Integer _ ) |
Parameters
- ringIndex
- Type: System..::.Int32
The index of the ring to remove.
Remarks
RemoveRing removes an entire ring from the Polygon; all other existing rings within the Polygon remain unchanged. Removing a ring from a Polygon changes the shape of the overall Polygon and may result in a Polygon which is not geometrically correct; for example, removing the outer ring from a Polygon would mean that any inner rings (holes) within the Polygon are no longer holes. Refer to the Simplify(Polygon) method for more information on correcting geometry.
Examples
The code below shows how the GetRing and RemoveRing methods and RingCount property can be used to turn one multipart Polygon into multiple
single part polygons. The code assumes there is an existing multipart Polygon called poly.
CopyC#
// Create a list to hold all the created polygons, System.Collections.Generic.List<Polygon> singlePrts = new System.Collections.Generic.List<Polygon>(pgon.RingCount); // Use RingCount and GetRing to iterate through every ring except the first ring in the polygon. for (int i = 1; i < pgon.RingCount; i++) { // Create a new Polygon from the ring, and add to the list. // Note - simplifying will correct turn any inner rings (holes) into outer rings (boundaries). Polygon newPoly = GeometryOperations.Simplify(new Polygon(pgon.GetRing(i))); singlePrts.Add(newPoly); } // Remove the subsequent rings from the original Polygon and add the original Polygon to the list. while (pgon.RingCount > 1) { pgon.RemoveRing(1); } singlePrts.Add(pgon);
CopyVB.NET
' Create a list to hold all the created Polygons, Dim singlePrts As System.Collections.Generic.List(Of Polygon) = New System.Collections.Generic.List(Of Polygon)(poly.RingCount) ' Use RingCount and GetRing to iterate through every ring except the first ring in the polygon. For i As Integer = 1 To poly.RingCount - 1 ' Create a new Polygon from the ring, and add to the list. ' Note - simplifying will correct turn any inner rings (holes) into outer rings (boundaries). Dim newPoly As Polygon = GeometryOperations.Simplify(New Polygon(poly.GetRing(i))) singlePrts.Add(newPoly) Next i ' Remove the subsequent rings from the original Polygon and add the original Polygon to the list. While poly.RingCount > 1 poly.RemoveRing(1) End While singlePrts.Add(poly)
Exceptions
Exception | Condition |
---|---|
System..::.ArgumentOutOfRangeException | The specified ringIndexmust exist in the Polygon. |
See Also
[O:ESRI.ArcGISExplorer.Geometry.Polygon.RemovePointAt]
[O:ESRI.ArcGISExplorer.Geometry.Polygon.RemovePointsAt]