0

I have several polygons from a drawing tool (eDraw) exported from the Web AppBuilder dev edition into a directory. They are exported in JSON format with a EPSG:3857 projection.

Through a script, I want to transform these JSON files to shapefiles, and store them in a different directory. This works perfectly, however there are three files that keep getting the error that they are out of bounds.

arcgisscripting.ExecuteError: ERROR 001558: Error parsing json file ''. The coordinates or measures are out of bounds.

I have tried to reproject them to no avail, I have tried to trace the failing polygons in the WAB and re-export them, but no luck. If I compare these three files to other files that do work I see no significant difference. Also, the two example files are right next to each other on the map, and I have no problem uploading the 'broken' JSON files to the drawing tool and display them in the right location on the map, so I do not understand how one can be passed with JSONToFeatures, and the other is out of bounds.

Working file:

{"features":[{"geometry":{"rings":[[[-8734229.349438265,-1044267.8697553115],[-8733964.208496368,-1044023.0323991263],[-8733867.46788243,-1044123.9531630479],[-8733481.69975528,-1043799.095792834],[-8733485.282740982,-1044816.6637318594],[-8733914.046696614,-1044820.8438817654],[-8734001.232681995,-1044775.4593962248],[-8733921.212668015,-1044651.249225272],[-8734229.349438265,-1044267.8697553115]]],"spatialReference":{"wkid":102100}},"attributes":{"name":"Scallops Peru 1 SAC ","description":"","objectid":1},"symbol":{"color":[255,199,198,99],"outline":{"color":[207,101,99,255],"width":0.75,"type":"esriSLS","style":"esriSLSSolid"},"type":"esriSFS","style":"esriSFSSolid"}}],"displayFieldName":"","fieldAliases":{},"spatialReference":{"wkid":102100},"fields":[{"name":"objectid","alias":"objectid","type":"esriFieldTypeOID"},{"name":"name","alias":"name","type":"esriFieldTypeString"},{"name":"description","alias":"description","type":"esriFieldTypeString"}]}

Not working file:

{"features":[{"geometry":{"rings":[[[-48806317.836461626,-1048103.3855233326],[-48806231.844804816,-1048077.1102948618],[-48805966.70386297,-1048325.5306367677],[-48806058.66716262,-1048642.0277069844],[-48806058.66716262,-1048788.9301207075],[-48806317.836461626,-1048790.1244492745],[-48806317.836461626,-1048103.3855233326]]],"spatialReference":{"wkid":102100}},"attributes":{"name":"Cultivos Casma SAC","description":"","objectid":1},"symbol":{"color":[255,199,198,99],"outline":{"color":[207,101,99,255],"width":0.75,"type":"esriSLS","style":"esriSLSSolid"},"type":"esriSFS","style":"esriSFSSolid"}},"displayFieldName":"","fieldAliases":{},"spatialReference":{"wkid":102100},"fields":[{"name":"objectid","alias":"objectid","type":"esriFieldTypeOID"},{"name":"name","alias":"name","type":"esriFieldTypeString"},{"name":"description","alias":"description","type":"esriFieldTypeString"}]}

This is part of the script:

import arcpy

import os

import json, sys

dirOfJSON = '<path>'

outputDIrectory = '<path>'

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)
  • Try translating your features by 40,075,016.685 meters (= the equatorial circumference of the Earth) in the X coordinate. For some reason, it looks like the coordinates were extended/wrapped around the Earth. – FSimardGIS Feb 14 at 13:38
  • There is definitely also syntax error in nonworking file: missing end of array character ] at the and of features array. – TomazicM Feb 14 at 14:10
  • 1
    Interesting. If I unproject a point from the nonworking file in the Esri projection engine directly, I get 9.37295S 78.43384W. If that's correct, the tool/script may be checking the valid area of the PCS and failing because it's outside the usual +/-180 range. – mkennedy Feb 14 at 22:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.