I am looking at features in an ArcSDE geodatabase via ArcMap. The feature shows to have four vertices by viewing the vertices in the map and by looking at the sketch properties.

However if I run a feature vertex to point tool i get 5 vertices. If I get an arcpy.SearchCursor row object and do row.pointCount I get 5 vertices reported.

I even exported the feature class out to a shapefile and got the same results.

Whats going on here? Thanks.

  • 1
    Isn't the feature a polygon? Then if the polygon ring is closed, you have the first and the last point the same.. – najuste Sep 19 '12 at 13:26
  • Are these polygons? If so, you may be seeing the start and end point (which are the same) showing up twice. Not in front of ArcMap right now to test, but will in a bit - @najuste beat me to the comment by a few seconds... – Chad Cooper Sep 19 '12 at 13:27

It sounds like you are working with polygons. I created a 4-corner polygon in a FGDB, and when I look at it in the editor, it does have 4 vertices:

enter image description here

However, when I run the following script on it, you can see it does indeed have 5 vertices (as it should), where the first and last are the same in order to close the polygon:

import arcpy

infc = "NumberOfVertices"
desc = arcpy.Describe(infc)
shapefieldname = desc.ShapeFieldName
rows = arcpy.SearchCursor(infc)
for row in rows:
    feat = row.getValue(shapefieldname)
    print "\tFeature %i:" % row.getValue(desc.OIDFieldName)
    partnum = 0
    for part in feat:
        parts = []
        print "Part %i:" % partnum
        for pnt in feat.getPart(partnum):
            if pnt:
                parts.append([pnt.X, pnt.Y])
                parts.append(" ")
        partnum += 1 
    print parts  

Part 0:
[[414609.77850000001, 3711987.8151999991], [421594.30240000039, 3711987.8151999991], [421926.89879999962, 3700346.9419999998], [414277.18209999986, 3701178.4329000004], [414609.77850000001, 3711987.8151999991]]

>>> len(parts)
  • 1
    Yeah, my guess is the last vertex is hidden to protect the user from accidentally making the geometry invalid. – blah238 Sep 19 '12 at 17:31
  • @blah238 Very good point. – Chad Cooper Sep 19 '12 at 18:10

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.