I am writing some VBA code to extract vertices from a polygon.

I would like to ask, how to select the vertices from a polygon ?

  • Please elaborate on what you mean by "select". Normally the selection environment keeps track of entire features, not parts of features like vertices. – Kirk Kuykendall Jan 31 '11 at 15:39

Once you have the Polygon, QI to IPointCollection. You can then iterate over all the points in this PointCollection which are the vertices that you need.

Here is some code which shows how to get the selected features & then get the geometry: I am writing this from memory, so it might not be exactly correct, but should give you an idea

Dim featureSelection As IFeatureSelection  
featureSelection =featureLayer 'featureLayer is of the type IfeatureLayer

Dim selectionSet As ISelectionSet 
selectionSet = featureSelection.SelectionSet

Dim cursor As ICursor
selectionSet.Search(null, false, cursor)

Dim row As IRow
row = cursor.NextRow()  

dim pPoly as IPolygon
Dim pPointColl as IPointCollection

    While Not row Is Nothing

         set pPoly=row.shapecopy
         set pPointColl= pPoly

        'now do whatever you want to with the vertices

         row = cursor.NextRow() 
    End While

If you have ArcInfo, you can use Feature Vertices to Points (Data Management) to extract the points.

However, these tools are available for Arc Toolbox (GUI), Arc console (FeatureVerticesToPoints_management), or via Python. Support for VBA is not provided.


Hi I have used code similar to that posted by Devdatta above, in my case to create SDOGeometry from edits to a shapefile. If you have multipart polygons or polygons with internal holes you have to get a bit more involved in the geometry. Start with the polygon and loop each external ring and check if each has any internal rings. It works but you need to be thourough unless you can guarantee your geometry will always be simple single parts with no holes.

On that point, does anyone know how to interpret the feature created by editing a polygon using the Arc Tool? This seems to only store a start and end point and my SDOGeometry feature obviously does not reflect the Arc. One the edit session is stopped the shapefile feature updates to relpace the Arc with a series of points approximating the Arc but I want to access it without stopping editing.

  • Welcome to the GIS SE Ian! Your question will have a better chance of being seen and answered if you post it as a new question. – sgrieve Nov 12 '12 at 16:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy