Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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]]]}}]}
share|improve this question

1 Answer 1

up vote 4 down vote accepted

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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