This is an issue related to this question I'd asked a few days ago. I've got that code working, to an extent. Every time, though, that I double click on one of the Polygons in the attribute table that I'd recently populated, ArcMap takes me to a point in the middle of Nebraska.
That's at 1:2500. If I zoom out, it just appears as an X in the middle of Nebraska. It's nearly the same for any of the Polygons I choose, except there are a different configuration of rectangles within that picture. But it's always in the middle of Nebraska.
I can go into the attribute table using python to pull out the polygon information with the Polygon getPart() method, and it looks like this:
Out[132]: <Array [<Array [<Point (-123.070983887, 43.0001220703, #, #)>, <Point
(-123.070983887, 45.5001220703, #, #)>, <Point (-121.890991211, 45.5001220703, #
, #)>, <Point (-121.890991211, 43.0001220703, #, #)>, <Point (-123.070983887, 43
.0001220703, #, #)>]>]>
...which, based on the points, should be in Oregon. But if I double click on it, it takes me to Nebraska. The other problem is that the polygons should be spread across the country (near national parks) but I think they're all getting bunched into that little square in Nebraska.
Does anyone know why this might be happening? Is the array-within-array throwing it off?
I'm adding the code that I used to create and fill the feature class. I created it with:
fcname = r'C:\Users\user\Documents\ArcGIS\parkpolys.shp'
output_fc = arcpy.CreateFeatureclass_management(os.path.dirname(fcname), os.path.basename(fcname), "Polygon")
And then filled it with:
def push_coords(coords):
"""Push a set of corner coords to featureclass record"""
cursor = arcpy.InsertCursor(fcname)
feat = cursor.newRow()
print 'new row created'
for corner in corners:
point.X = corner[0]
point.Y = corner[1]
array.add(point)
array.add(array.getObject(0))
polygon = arcpy.Polygon(array)
feat.shape = polygon
cursor.insertRow(feat)
array.removeAll()
del feat
del cursor
# Corners list format: ["lowerLeft", "lowerRight", "upperRight", "upperLeft"]
#new format: ["lowerLeft", "upperLeft", "upperRight", "lowerRight"]
cursor = arcpy.SearchCursor("gmaps")
for row in cursor:
corners = [[row.getValue('xmax'), row.getValue('ymin')],
[row.getValue('xmax'), row.getValue('ymax')],
[row.getValue('xmin'), row.getValue('ymax')],
[row.getValue('xmin'), row.getValue('ymin')]]
push_coords(corners)