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.
-
1Isn't the feature a polygon? Then if the polygon ring is closed, you have the first and the last point the same..najuste– najuste2012年09月19日 13:26:35 +00:00Commented Sep 19, 2012 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– Chad Cooper2012年09月19日 13:27:26 +00:00Commented Sep 19, 2012 at 13:27
1 Answer 1
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])
else:
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)
5
>>>
-
1Yeah, my guess is the last vertex is hidden to protect the user from accidentally making the geometry invalid.blah238– blah2382012年09月19日 17:31:11 +00:00Commented Sep 19, 2012 at 17:31
-
@blah238 Very good point.Chad Cooper– Chad Cooper2012年09月19日 18:10:01 +00:00Commented Sep 19, 2012 at 18:10