Any thoughts?
If I copy this JSON from this location (web link) to a local file I can import to File GDB.
import arcpy
import os
arcpy.env.workspace = r"C:\Users\xx\Desktop\GIS\IMPORT DEQ DATA"
arcpy.conversion.JSONToFeatures("myjsonfeatures.json", os.path.join("Datasets.gdb", "myfeatures"))
But I want to read the URL live as I want to run this script a couple times a day. How do I do that...
I tried the below but does not work
import arcpy
import os
geoJSON = "https://apps.deq.virginia.gov/arcgis/rest/services/public/EDMA/MapServer/104/query?outFields=*&where=1%3D1&f=geojson"
arcpy.env.workspace = r"C:\Users\xxx\Desktop\GIS\IMPORT DEQ DATA"
arcpy.conversion.JSONToFeatures(geoJSON, os.path.join("DEQ_Datasets.gdb", "myfeatures"))
", line 512, in <lambda>
return lambda *args: val(*gp_fixargs(args, True))
arcgisscripting.ExecuteError: Failed to execute. Parameters are not valid.
ERROR 000814: Invalid file type
Failed to execute (JSONToFeatures).
Solved! Go to Solution.
Think the only thing you can do is write it to a file each time since the JSONToFeatures needs a txt file input. You can use the json dumps to write it.
with open("sample.json", "w") as outfile:
json.dump(injson, outfile)
Think the only thing you can do is write it to a file each time since the JSONToFeatures needs a txt file input. You can use the json dumps to write it.
with open("sample.json", "w") as outfile:
json.dump(injson, outfile)
So I cannot read it live into the Feature Class... I have to write it local everytime?
You could go the Json to pandas df, then df to dictionary, then to featureclass to keep it stateless, but if you want to use the JSONToFeatureclass method, then you'll have to write it to a file each time.
Is there any other way possible to do this with the service URL I provided?