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
RuntimeError: Object: Error in executing tool
. See the Traceback for details.