1

I want to convert some json data being returned from a request to a feature class, but I keep getting a RuntimeError: Object: Error in executing tool. I made a test gdb in a folder 'C:/Workspace/Sandbox/ScratchTests/cslf.gdb' in which to populate my new feature class after conversion. To test that the request is correct and that I am returning Json data, I added a couple of print statements. Otherwise, everything is pretty straight forward. Does anyone see a problem with my code? I am following the arcpy [JSON to Features][1] directions from the documentation. The only thing I am doing differently is instead of using an actual file, I am just plugging in the variable 'cslfJson`.

import arcpy, sys, os, arcgis, requests
arcpy.env.workspace = "C:/Workspace/Sandbox/ScratchTests"

params = {'f': 'json', 'where': '1=1', 'geometryType': 'esriGeometryPolygon', 'spatialRel': 'esriSpatialRelIntersects','outFields': '*', 'returnGeometry': 'false'}
r = requests.get('https://hazards.fema.gov/gis/nfhl/rest/services/CSLF/Prelim_CSLF/MapServer/3/query', params)
print(r.url)

cslfJson = r.json()
print(cslfJson)

arcpy.JSONToFeatures_conversion(cslfJson, os.path.join("cslf.gdb", "cslf"))

Also, Here's the Traceback:

https://hazards.fema.gov/gis/nfhl/rest/services/CSLF/Prelim_CSLF/MapServer/3/query?f=json&where=1%3D1&geometryType=esriGeometryPolygon&spatialRel=esriSpatialRelIntersects&outFields=%2A&returnGeometry=false Traceback (most recent call last):

File "", line 1, in runfile('C:/Workspace/Sandbox/ScratchTests/CSLF.py', wdir='C:/Workspace/Sandbox/ScratchTests')

File "C:\Users\jbridwell\AppData\Local\Continuum\anaconda3\envs\acrpro\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 668, in runfile execfile(filename, namespace)

File "C:\Users\jbridwell\AppData\Local\Continuum\anaconda3\envs\acrpro\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 108, in execfile exec(compile(f.read(), filename, 'exec'), namespace)

File "C:/Workspace/Sandbox/ScratchTests/CSLF.py", line 20, in arcpy.JSONToFeatures_conversion(cslfJson, os.path.join("cslf.gdb", "cslf"))

File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\conversion.py", line 403, in JSONToFeatures raise e

File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\conversion.py", line 400, in JSONToFeatures retval = convertArcObjectToPythonObject(gp.JSONToFeatures_conversion(*gp_fixargs((in_json_file, out_features), True)))

File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing_base.py", line 506, in return lambda *args: val(*gp_fixargs(args, True))

RuntimeError: Object: Error in executing tool

[1]: http://desktop.arcgis.com/en/arcmap/10.3/tools/conversion-toolbox/json-to-features.htm

3
  • whats the error you're getting? there was a known BUG in their PRO release be sure to have the latest patch to circumvent this known issue.
    – NULL.Dude
    Aug 20, 2018 at 13:37
  • Hmmm, I'll add the traceback, but actual error I'm seeing (I'm using Spyder with Python 3.6 from AcrGIS Pro), was RuntimeError: Object: Error in executing tool. See the Traceback for details.
    – gwydion93
    Aug 20, 2018 at 13:51
  • yah be sure to install the 2.2 patch
    – NULL.Dude
    Aug 20, 2018 at 16:35

2 Answers 2

1

Be sure to have the latest ArcGIS PRO patch release (2.2.1)

There were known issues in previous releases dealing with JSON conversions.

  • BUG-000115464

GeoJSON to Features crashes ArcGIS Pro at GPCoreFunctions!Bucket_JSON2F::UnionProperties (gpesrijsontofeaturesfunction.cpp @ 1029).

  • BUG-000110564

The Key Metadata function fails to run a JSON Metadata String in ArcGIS Pro, even with a valid input.

these BUGS are not limited to your issue but will affect your processing. Implement the patch and see if it clears the problem.

2
  • I'm running 2.1.2. Will the latest patch work with my version (2.2)?
    – gwydion93
    Aug 20, 2018 at 19:02
  • no you need to update PRO to 2.2.1
    – NULL.Dude
    Aug 20, 2018 at 19:14
0

I was actually able to get this to work without updating to 2.2. Essentially, I had to turn the json data into a physical file in order for it to work. This is a little cumbersome, but as the file should get overwritten each time I run the script (as the REST service data is updated) it should be fine. I just added a part at then end to open a file and then write to that file, then use the newly created json file in JSONToFeatures_conversion:

cslfJson = r.json()
path = r"C:/Workspace/Sandbox/ScratchTests/cslf.json"
with open(path, 'w') as f:
     json.dump(cslfJson, f, indent=2)

arcpy.JSONToFeatures_conversion("cslf.json", os.path.join("cslf.gdb", "cslf"))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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