I've got the results of a map service query urlib2.Request setup as
jsonResult = json.load(response)
From this I am attempting to setup an in_memory FeatureSet() but it is failing when fs.load(jsronResult) with "RuntimeError: RecordSetObject: Cannot open table for Load".
The odd thing is this works if I write the jsonResult to a local .json file and then issue arcpy.JSONToFeatures_conversion() with the same exact contents as the jsonResult payload.
Anyone have similar scenario? Must be something simple I'm missing here.
Thanks!
qryLandUseURL <SPAN class="operator token">=</SPAN> <SPAN class="string token">'https://SomeAGSurl/MapServer/0/query'</SPAN>
qryLandUseParams <SPAN class="operator token">=</SPAN> urllib<SPAN class="punctuation token">.</SPAN>urlencode<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">{</SPAN><SPAN class="string token">'f'</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="string token">'pjson'</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">'geometryType'</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="string token">'esriGeometryPolygon'</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">'geometry'</SPAN><SPAN class="punctuation token">:</SPAN> inGeometry<SPAN class="punctuation token">,</SPAN><SPAN class="string token">'spatialRel'</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="string token">'esriSpatialRelIntersects'</SPAN><SPAN class="punctuation token">,</SPAN><SPAN class="string token">'outFields'</SPAN><SPAN class="punctuation token">:</SPAN> flds<SPAN class="punctuation token">,</SPAN><SPAN class="string token">'returnGeometry'</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="string token">'true'</SPAN><SPAN class="punctuation token">}</SPAN><SPAN class="punctuation token">)</SPAN>
qryLandUseReq <SPAN class="operator token">=</SPAN> urllib2<SPAN class="punctuation token">.</SPAN>Request<SPAN class="punctuation token">(</SPAN>qryLandUseURL<SPAN class="punctuation token">,</SPAN> qryLandUseParams<SPAN class="punctuation token">)</SPAN>
response <SPAN class="operator token">=</SPAN> urllib2<SPAN class="punctuation token">.</SPAN>urlopen<SPAN class="punctuation token">(</SPAN>qryLandUseReq<SPAN class="punctuation token">)</SPAN>
jsonResult <SPAN class="operator token">=</SPAN> json<SPAN class="punctuation token">.</SPAN>load<SPAN class="punctuation token">(</SPAN>response<SPAN class="punctuation token">)</SPAN>
fs <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>FeatureSet<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
fs<SPAN class="punctuation token">.</SPAN>load<SPAN class="punctuation token">(</SPAN>jsonResult<SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>Edit: my original implementation works when I set the fs.load() to the url of the map service like this:
rquery <SPAN class="operator token">=</SPAN> <SPAN class="string token">"?where={}&outFields={}&returnGeometry=true&f=json"</SPAN><SPAN class="punctuation token">.</SPAN>format<SPAN class="punctuation token">(</SPAN>rwhere<SPAN class="punctuation token">,</SPAN> rflds<SPAN class="punctuation token">)</SPAN>
rqueryfsURL <SPAN class="operator token">=</SPAN> rtaburl <SPAN class="operator token">+</SPAN> rquery
rfs <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>FeatureSet<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN>
rfs<SPAN class="punctuation token">.</SPAN>load<SPAN class="punctuation token">(</SPAN>rqueryfsURL<SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>But I need it to have an input geometry and spatialRel type instead of a simple WHERE clause.