AnsweredAssumed Answered

RuntimeError: Object: CreateObject cannot create geometry from inputs

Question asked by devonc1301 on Oct 31, 2017
Latest reply on Oct 31, 2017 by devonc1301

I cannot seem to create a geometry using a list of coordinates. I'm parsing these coordinates from a JSON object, which I have successfully tested, but from the documentation it seems this should work once I have a double to input. Here is another similar example.

 

import arcpy, json

 

jsonObj = """{
"points": [
    {
      "Y": 35.631453769591765,
      "X": -97.586939334869385
    },
    {
      "Y": 35.628907432142576,
      "X": -97.587132453918457
    },
    {
      "Y": 35.627703997864323,
      "X": -97.589900493621826
    },
    {
      "Y": 35.630180611005642,
      "X": -97.590758800506592
    },
    {
      "Y": 35.630302695584653,
      "X": -97.5909948348999
    },
    {
      "Y": 35.631453769591765,
      "X": -97.586939334869385
    }
  ],
  "spatialReference": {
    "wkid": 4326
  }
}"""

 

dictionary = json.loads(jsonObj)

 

#the Polygon method fails whether I input a list of Points or PointGeometries

coordsList = []
for items in dictionary["points"]:
    pt = arcpy.Point(items["X"], items["Y"])
    coordsList.append(arcpy.PointGeometry(pt, arcpy.SpatialReference(4326)))


geometry = arcpy.Polygon(coordsList, arcpy.SpatialReference(4326)) #fails here

# arcpy.CopyFeatures_management(geometry, FILEPATH)

Outcomes