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.

attribute zoom

1:2,500 scale 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]
    polygon = arcpy.Polygon(array)
    feat.shape = polygon
    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')]]
  • If you're willing to install QGIS as an alternative toolkit, I'd suggest reviewing that feature's geometry as a Well Known Text expression, so we can see what its actual vertices. I wouldn't be surprised if that is a wierdo geometry. This answer says how to perform the WKT export---but I'd further recommend setting a layer definition first, so you export only the rogue feature(s).
    – elrobis
    Apr 16 '13 at 22:44
  • 5
    Does the layer have a defined coordinate system? If so, what is it? And what's the data frame's coordinate system? If the DF was using something like USA Albers, the (0,0) point of that coordinate reference system could be near Nebraska...
    – mkennedy
    Apr 16 '13 at 23:05
  • The layer actually is using Albers. The coordinate system for the feature class is <Undefined>. I'll have to look into what they should be. Apr 16 '13 at 23:37
  • If I change the coordinate system for both to NAD83, the results look correct. Thanks. Apr 17 '13 at 1:06

according to the question you asked before, the polygon's points are putting in counter-clockwise and this means interior rings in ArcGIS. Instead, you must put points in clockwise and create exterior rings. I guess polygons extent are broken.

  • I changed the corners array so that it read the points in clockwise fashion - ["lowerLeft", "upperLeft", "upperRight", "lowerRight"] and still getting the same problem. Apr 16 '13 at 21:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.