1

I have a folder on my local drive with 1,500+ JSON files (lines) that I need converted to shapefiles. I've tried creating a batch model in Python and ModelBuilder without success.

I'm using ArcGIS 10.2 and PyScripter.

Via KHibma: (this is not yet working for me, maybe someone can chime in)

import arcpy
import os

dirOfJSON = 'c:/temp/jsons'
outputDIrectory = 'c:/temp/jsonSHPs'

arcpy.env.workspace = dirOfJSON

for f in arcpy.ListFiles('.json'):
    j = os.path.join(dirOfJSON, f)
    outputShp = os.path.join(outputDIrectory, os.path.splitext(f)[0] + ".shp")
    print("Processing : {}".format(outputShp))
    arcpy.JSONToFeatures_conversion(j, outputShp)
  • Which software are you using? – whyzar Nov 2 '16 at 16:09
  • Rather similar question today gis.stackexchange.com/questions/216281/…. Same approach will work, not much to do with GIS really. – user30184 Nov 2 '16 at 16:16
  • I'm using ArcGIS 10.2 and Pyscripter. – Daniel Nov 2 '16 at 16:42
  • Does JSONToFeatures work on a single JSON file of yours? What happens when you run that code snippet? – PolyGeo Nov 2 '16 at 21:40
0

Give this a whirl, make sure to update the directories.

import arcpy
import os

dirOfJSON = 'c:/temp/jsons'
outputDIrectory = 'c:/temp/jsonSHPs'

arcpy.env.workspace = dirOfJSON

for f in arcpy.ListFiles('.json'):
    j = os.path.join(dirOfJSON, f)
    outputShp = os.path.join(outputDIrectory, os.path.splitext(f)[0] + ".shp")
    print("Processing : {}".format(outputShp))
    arcpy.JSONToFeatures_conversion(j, outputShp)
  • This does not seem to give me any response when run through PyScripter or Python module in ArcMap. I did also update the directories on the script. – Daniel Nov 2 '16 at 18:28

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