how get vertices of polygon?

3046
2
11-29-2010 10:58 AM
StefhanCampos
New Contributor
hi,
       how I can getting vertices from polygon?another question how i can convert or get
polylines from polygon?


ps:version 9.3 and api 1.2...but i can use 2.1
0 Kudos
2 Replies
JenniferNery
Esri Regular Contributor
To get the vertices of a polygon, you need to go through the Rings of the polygon where each Ring is a PointCollection and each collection is composed of MapPoints (vertices).

Something like:
PointCollection vertices = new PointCollection();
for (int i = 0; i < polygon.Rings.Count; i++)
 foreach (var mp in polygon.Rings)
  vertices.Add(mp);


To convert this to a polyline geometry, you need to create a Path for every Ring where each Ring and Path contain the same PointCollection.
0 Kudos
dotMorten_esri
Esri Notable Contributor
To convert polygon to polyline, just move the rings over to the paths:
 
Polyline line = new Polyline();
foreach(var ring in myPolygon.Rings)
    line.Paths.Add(ring);
0 Kudos