Stuart.Moore

Create a polygon grid has some odd results

Discussion created by Stuart.Moore on Feb 24, 2013
Latest reply on Feb 25, 2013 by jskinner-esristaff
Hi,
ive created the below code to create a polygon grid 2 squares wide and 1 high, the code works fine and creates the grid with the attributes but when i select one of the squares in arcMap the highlight selects both (screenshot attached)

any ideas as to what ive done wrong?

Thanks

Stu

import arcpy

cur = arcpy.InsertCursor("c:/PY123.shp")

point = arcpy.Point()
array = arcpy.Array()

for x in range(2):
    for y in range(1):
        point.X = x
        point.Y = y
        array.add(point)
        point.X = x+1
        point.Y = y
        array.add(point)
        point.X = x+1
        point.Y = y+1
        array.add(point)
        point.X = x
        point.Y = y+1
        array.add(point)
        point.X = x
        point.Y = y
        array.add(point)
        array.add(array.getObject(0))
        feat = cur.newRow()
        feat.setValue("Col", x)
        feat.setValue("Row", y)
        feat.shape = arcpy.Polygon(array)
        cur.insertRow(feat)
        array.removeAll()

del cur

Attachments

Outcomes