2

I have the following code:

feature_geometry = arcpy.AsShape(json_string, esri_json=True)
print feature_geometry
print type(feature_geometry)
>>><geoprocessing record set object object at 0x0E1D9F20>
>>><class 'arcpy.arcobjects.arcobjects.RecordSet'>

It's returning a record set however the documentation says it should return a geometry object... What I am missing?

This is the ESRI_JSON object I'm passing:

{"displayFieldName":"","fieldAliases":{"OBJECTID":"OBJECTID","SHAPE_Length":"SHAPE_Length"},"geometryType":"esriGeometryPolyline","spatialReference":{"wkid":102100,"latestWkid":3857},"fields":[{"name":"OBJECTID","type":"esriFieldTypeOID","alias":"OBJECTID"},{"name":"SHAPE_Length","type":"esriFieldTypeDouble","alias":"SHAPE_Length"}],"features":[{"attributes":{"OBJECTID":2,"SHAPE_Length":27314.085654472176},"geometry":{"paths":[[[-12374196.4669,7608025.6432999969],[-12373633.217700001,7580717.365699999]]]}}]}

1 Answer 1

4

This is by design, you are sending it a feature set and not a singular geometry.

If you'd like the Geometry on its own, do this:

import json
geom = arcpy.AsShape(json.loads(json_string)["features"][0]["geometry"], True)

We thought in many cases people would like to parse full Esri JSON feature sets and not just individual geometries, so that's why it works the way it does.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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