import arcpy, os
arcpy.env.workspace = "U:\Tax\Special Projects\JEFitzgerald\CUVA\2014\CUVA_PYTHON_06252014_Final\CUVA.mdb"
pointList=[]
#Finds the field named File and deletes it
try:
with arcpy.da.UpdateCursor("GC_R20_Polygon",("File"),'[File] =\'Done\'') as cursor:
cntr = 1
for row in cursor:
cursor.deleteRow()
print "Record number "+ str(cntr) + " deleted"
cntr = cntr + 1
except Exception as e:
print e.message
#**** CODE for R20 ****#
try:
with arcpy.da.SearchCursor ("GC_R20", ["SHAPE@XY"]) as cursor:
for row in cursor:
xy = row[0]
pointList.append(xy)
with arcpy.da.InsertCursor ("GC_R20_Polygon", ["SHAPE@"]) as U:
for pnt in pointList:
lowX = pnt[0]
lowY = pnt[1]
# find the upper right
highX = lowX + 162.2539
highY = lowY + 123.2639
array = arcpy.Array([arcpy.Point(lowX, lowY),
arcpy.Point(lowX, highY),
arcpy.Point(highX, highY),
arcpy.Point(highX, lowY),
arcpy.Point(lowX, lowY)])
polygon = arcpy.Polygon(array)
U.insertRow([polygon])
#Populates a field with DONE so the delete cursor will find and delete.
#This will enable a clean attribute table so dublicates will be eliminated.
arcpy.CalculateField_management("GC_R20_Polygon","File", "\"Done\"", "PYTHON", "")
print "Process for new polygons is complete"
print "James E. Fitzgerald, GISP, GIS Specialist"
except:
print