Using a Python script, we are pulling a list of polygon vertices from a web service to build a polygon and insert it into our SDE.
The problem steps are happening when we're making an arcpy.Polygon geometry object out of an arcpy.Array of arcpy.Points. There are 95 points listed in the JSON, 95 points in the
polygon_array... and then not 95 points in the resulting arcpy.Polygon.
- If it's created with no spatial reference, the polygon
pointCounthas 11 points
- If it's created with WGS84 (which matches the lat/long projection of the source data), the polygon
pointCounthas 1126 (!) points
Why does the resulting polygon have such a different number of vertices (either less or more) than it's being handed? Is it possible for misordered vertices that would cause geometry problems to be "weeded out" by the arcpy.Polygon instantiation — but if so, I'm even more baffled by the WGS84 polygon having over a thousand points!
# add points to array polygon_array = arcpy.Array() for point in polygon_data: polygon_array.add( arcpy.Point( polygon_data[point]['Value']['Longitude'], polygon_data[point]['Value']['Latitude'] ) ) # print the length of the array of points print(polygon_array.count) # prints 95 sr = arcpy.SpatialReference(4326) polygonObj = arcpy.Polygon(polygon_array, sr) # Print the amount of points in our polygon print(polygonObj.pointCount) # prints 1126
(This is running with ArcGIS Desktop 10.2.1.)