AnsweredAssumed Answered

Export item JSON where clause 

Question asked by H.Bouckaert_westernpower on Aug 6, 2018

Hi 

 

I am trying to use the export functionality for an item in Portal, to export to a File geodatabase and then download the File geodatabase to the local drive. However I want to use a where clause so I only download certain records. The method for exporting to a File geodatabase is described here: 

 

arcgis.gis module — arcgis 1.4.2 documentation 

 

with a further link to this page where the JSON for using a where clause is described: 

 

Export Item—ArcGIS REST API: Users, groups, and content | ArcGIS for Developers 

 

However, the JSON, as described above does nor work. I have tried the format 

 

{ "layers" :[ {"id" : 0 }, {"id" : 1, "where" : "POP1999 > 100000"} ] }

 

and applied this to my own situation i.e. using the same format, but specifying that a field named "pip" should have value 1 (after checking that the field name is 'pip', in the layer, that it is an integer and has values 1. Note however that this is a domain field. So I have also tried the domain description where 'Yes' is used instead of 1, and even have used the field alias instead of the field name.

 

The where clause is to be applied to layer 0. So I have: 

 

exportParameters = [ {"id" : 0, "where" : "pip = 1"}]

Then I export (where "fl" is my feature layer collection) 

exportfgdb = fl.export(title=feature_layer+'_Export', export_format='File Geodatabase', parameters=exportParameters, wait=True)

And download: 

exportfgdb.download(save_path=download_location)

 

But I always get all the data, never what is specified by my where clause. I even tried

 

"where": "OBJECTID < 10"

 

But that does not work either. 

 

Note that I have a related table in the feature layer collection, which is listed in Portal as layer 1. So even if I just try to download layer 0 and not layer 1 (without any where clause), that does not work either: 

 

exportParameters= {"layers" : [ { "id" : 0 } ] } 

 

So I am thinking that the JSON is simply not read because it is all wrong. But what is the right syntax for the JSON when doing an export? There seems to be no documentation on this apart from the above link, so I have been trying just  about all the combinations that can be made, but nothing works.

 

Any help will be greatly appreciated. 

 

Thanks

 

Hugo  

Outcomes