AnsweredAssumed Answered

arcpy insert cursor problem - adding multiple polygons

Question asked by RJW on Nov 13, 2014
Latest reply on Nov 13, 2014 by RJW

I am reading rows from a database with a field "Coords" that contains polygon coordinates in the format 40.090170,-83.007704|40.089878,-83.007724..... and inserting each row as a polygon.


The first feature is drawn correctly, the second feature is drawn but  is connected to and duplicates the first feature, and the third contains all three and so on.


The coordinates are cumulative (not intentionally).  I tried deleting variables between iterations, but that didn't help.  What am I missing?



    import pypyodbc     import arcpy     GdbFeat = r"\\server\Arc_Server_data\publish.gdb\OUPS"     spatialRef = arcpy.Describe(GdbFeat).spatialReference     conn = pypyodbc.win_connect_mdb(r"C:\GIS\db\COWOUPSx.mdb")     cursor = conn.cursor()     cursor.execute("SELECT TicketDate, TicketNum, Coords FROM Tickets WHERE (((TicketDate) = #11/15/2014#))")     rows = cursor.fetchall()     cursor.close     del cursor     conn.close     del conn     if rows:                     polygonArray = arcpy.Array()             for row in rows:                                     Coords = row[6]                     coordinatePairList = Coords.split("|")                     for coordinatePair in coordinatePairList:                             coordinates = coordinatePair.split(",")                             currentPoint = arcpy.Point(coordinates[1],coordinates[0])                                                     polygonArray.add(currentPoint)                                                                                polygon = arcpy.Polygon(polygonArray, spatialRef)                                     polygonArray.removeAll                                     with arcpy.da.InsertCursor(GdbFeat, ("Shape@", "TicketDate", "TicketNum")) as Acursor:                             Acursor.insertRow((polygon, row[0], row[1]))                                                          del Coords                                 del polygon                     del coordinatePairList                     del coordinatePair                     del coordinates                     del currentPoint                                  del row             del rows