I have a script that generates a mesh network from vertex and centroid inputs, and it works for almost all my points. But for some records that get created in the feature class via the script, their geometry record is "None" instead of a geometry object when I check it's state via describe, with an area of zero. I've manually inspected my data at these points and the values are definitely valid.

import arcpy, numpy, os

arcpy.env.workspace = "TarVis.gdb"
centerpoints = os.path.join(workspace, "ngofs_centroids_table")
cornerpoints = os.path.join(workspace, "ngofs_vertex_table")

print "Loading Centers"
centerFields = ["CID","VID1", "VID2", "VID3"]
center_array = arcpy.da.TableToNumPyArray(centerpoints, centerFields)

print "Loading corners"
cornerFields = ["VID","LON","LAT"]
corner_array = arcpy.da.TableToNumPyArray(cornerpoints, cornerFields)

vertex_dict = {} # create vertex dictionary with values as Point geometry
for corners in corner_array:
    vertex_dict[corners["VID"]] = arcpy.Point(corners["LON"], corners["LAT"])
    print "Loading Vertexes:"  + str(corners)

poly_dict = {} # create polygon geometry with polygon objects
for centers in center_array:
    poly_dict[centers["CID"]] = arcpy.Polygon(arcpy.Array([vertex_dict[centers["VID1"]],vertex_dict[centers["VID2"]],vertex_dict[centers["VID3"]]]))
    print "Making Polys:" + str(centers)

# create new feature class mesh_net
mesh_net = arcpy.CreateFeatureclass_management(workspace, "ngofs_mesh", "POLYGON", has_m="DISABLED")
with arcpy.da.InsertCursor(mesh_net, ["OID@", "SHAPE@"]) as cursor: # load polygons into feature class
    for poly in poly_dict.keys():
        cursor.insertRow([poly, poly_dict[poly]])
        print "Loading Polys:" + str(poly)

Odd things I have noticed from this output:

  • the resulting featureClass has Domain values that shouldn't be able exist (+/-450359962737.05 for all Max/Min extents in decimal degrees???) as well as relatively high XY Resolution and Tolerance. I can't figure out how/why it's determining any of this information.
  • this only occurs in places where the resulting polygon would have a very small area relative to the rest of the mesh and where the vertexes and centroids are thus clustered together very tightly.

Any ideas or starting points for what could be going on here?

My original question for reference, it explains what I am trying to accomplish in greater detail: Alternative to an arcpy script for points to lines to polygons?

So far the only method I've found to get around these empty polygons forming is to run through the tool chain of PointsToLines and then FeatureToPolygon, writing this polygon feature to memory and then extracting it's geometry from it using a searchCursor and assigning it to it's appropriate key in the dictionary (much better than my original implementation, this takes about a second to run per poly). However, I noticed that when I was running this tool I sometime somes cluster_tolerance property would throw a maximum tolerance exceeded error, so I included a statement to lower the tolerance distance until it works or until the 11th decimal place. This gives me a thought: could the arcpy. Polygon declaration have it's own tolerance parameters?

This worked for a sample set but is now breaking on the larger one, the error is

ExecuteError: ERROR 999999: Error executing function.
Invalid Topology [Y coord limit exceeded.]
Failed to execute (FeatureToPolygon).

So while I'm quadruple checking my datasets for validity (again), if anyone has any more insight they can offer please do, I don't like my options at this point for getting this sorted out because they're looking to be manual and I don't have time to manually create and attirbute 1500 of these broken polygons :(

I may have identified the actual problem that is occurring - https://gis.stackexchange.com/a/37681/50716 in reference to my problem, I notice that my table values across all my featureclasses are being truncated at the 6th place, and those polygons are potentially small enough in area that they are being automatically reduced to zeroes. At least, this is what I'm thinking.

  • ArcPy denotes the start of an internal ring using a None object. I don't know why this would happen, though. My only suggestion is in your arcpy.Array(), try repeating the first vertex at the end to "close" the polygon. – dmahr Apr 24 '15 at 19:24
  • 1
    When creating the polygon object, make sure to use a spatial reference. Coordinates otherwise might be getting collapsed. – DWynne Apr 24 '15 at 19:40
  • Spatial reference is a must, @DWYynne is right. Without it arcpy treates numerics as single precision instead of double. Very bad for decimal degrees things. Also triangle should have 4 points, where 4th=1st – FelixIP Apr 24 '15 at 22:32
  • I have a spatial reference set in my geodatabase I believe, but I will add it to be sure. Will give repeating the first coordinate a go, see what happens. – 4xle Apr 24 '15 at 23:37
  • No joy, unfortunately. Still have polygons that don't exist. – 4xle Apr 25 '15 at 0:54

As commented by the asker:

Finally figured this out yesterday. Somehow, have no idea how, I was ending up with TWO spatial reference systems attached to the same feature class extracted from the results of manually creating an XY layer in ArcMap - a geographic one first and a projected one second. The polygon creation was referencing the projected system, which was in meters, but with values in degrees, which was what was created such huge extents. Not sure why some polygons would collapse when others wouldn't, but recreating the vertex layer with only a single geographic coordinate reference fixed everything.

| improve this answer | |

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