abigail_gleason

lat/long verticies from polygons

Discussion created by abigail_gleason on Feb 28, 2014
Latest reply on Feb 28, 2014 by jcscott
Hello,

   I am currently working with a polygon shapefile in ArcMap 10.0.  I would eventually like to generate a text file containing the X/Y latitude and longitude coordinates from each vertice in the shapefile. I have read the desktop help for 10.0 regarding reading geometries, as well as a forum post from March 2012 labeled  ???Extracting X, Y, Z from line features vertices and create a point feature class". From these two sources it seems relatively straight forward to at least generate a printout of the vertices.  However, after following the help document exactly, I received the message that the "Row" oject is not iterable. When I convert my shapefile to points using the Feature vertices to points tool and then use the portion of the help document regarding reading point geometries, the vertices are printed without any issue.
As a sanity check, is there something simple I'm missing about the procedure? Below is the method I adapted using the Desktop help document.
Thank you very much,
Abby


desc = arcpy.Describe(infc)
shapefieldname = desc.ShapeFieldName

rows = arcpy.SearchCursor(infc)

for row in rows:
    feat = row.getValue(shapefieldname)

    print "Feature %i:" % row.getValue(desc.OIDFieldName)
    partnum = 0

    for part in feat:
        print "Part %i:" % partnum

        for pnt in feat.getPart(partnum):
            print pnt.X, pnt.Y
        partnum += 1

Outcomes