esri_json = {"paths" : [[[-97.08, 32.8], [-97.05, 32.6], [-97.06, 32.7], [-97.07, 32.6]], [[-97.4, 32.5], [-97.2, 32.75]]], "spatialReference" : {"wkid" : 4326}} polyline = arcpy.AsShape(esri_json, True) >>> # returns Traceback (most recent call last): File "<editor selection>", line 1, in <module> TypeError: AsShape() takes exactly 1 argument (2 given)
Traceback (most recent call last): File "<editor selection>", line 6, in <module> AttributeError: 'PointGeometry' object has no attribute 'JSON'
Solved! Go to Solution.
# GeoJSON --> esri Python : arcpy.AsShape(x) # GeoJSON --> esri JSON : arcpy.AsShape(x).JSON # esri Python --> GeoJSON : geojson-madness.geometry_to_struct(x) # esri Python --> esri JSON : x.JSON # esri JSON --> esri Python : arcpy.AsShape(x, True) # esri JSON --> GeoJSON : geojson-madness.geometry_to_struct(arcpy.AsShape(x, True))
// esri JSON --> esri JSAPI : esri.geometry.jsonUtils.fromJson(json) // GeoJSON --> esri JSAPI : Terraformer.ArcGIS.convert(...) // esri JSON --> GeoJSON : Terraformer.ArcGIS.parse(...) // esri JSAPI --> GeoJSON : Terraformer.ArcGIS.parse(...) // esri JSAPI --> esri JSON : esri JSON is representation of esri JSAPI // GeoJSON --> esri JSON : Terraformer.ArcGIS.convert(...)
crs_wgs84 = {'type': 'EPSG', 'properties': {'code': 4326}} crs_osgb = {'type': 'EPSG', 'properties': {'code': 27700}}
//{"wkid" : <wkid>, "latestWkid" : <wkid>, "vcsWkid" : <wkid>,"latestVcsWkid" : <wkid>} var web_mercator = {"wkid" : 102100, "latestWkid" : 3857 } var osgb = {"wkid": 27700}
import arcpy import json from osgeo import gdal from osgeo import ogr import shapely # https://pypi.python.org/pypi/Shapely import pysal # http://pysal.readthedocs.org/en/latest/index.html import geojson-madness # https://github.com/jasonbot/geojson-madness
A couple of comments since this is an older thread. Since 2014, Esri started support GeoJSON with Features To JSON—Help | ArcGIS Desktop at ArcGIS 10.5, which is handy for exporting sets of geometry objects to GeoJSON. Unfortunately, sadly, JSON To Features—Help | ArcGIS Desktop still does not support GeoJSON at ArcGIS 10.6.
Also, since 2014, the GeoJSON has been formally adopted as RFC 7946 - The GeoJSON Format . Although what the IETF adopted was mostly the same, there are some important differences in the standard, most notably with the removal of alternative coordinate reference systems. GeoJSON is now all ESPG: 4326.