I have a public hosted feature in ArcGIS Online (test data) which has SYNC enabled.
Using the Python API I want to download a file geodatabase, but also include a WHERE clause to download a subset of the data.
I am having a problem with the WHERE clause.
I can perform a standard REST query to get some records from an individual layer.
I can also successfully download a file geodatabase using the createReplica endpoint via REST:
However, if I want to apply a WHERE clause, I am having some problems getting the layerQueries parameter to work via REST
{"0":{"queryOption": "useFilter", "where": "type = JAM", "useGeometry": false}}
{"0":{"where": "type = JAM"}}
Both of the above result in:
Exporting data for layer 0 failed.
I intend on using this via Python as below, but I figure I need to be able to get it work directly against the REST API before troubleshooting in Python.
replica = waze_flc.replicas.create(replica_name = 'Waze_Download',
layer_queries = {"0":{"queryOption": "useFilter", "where": "type = JAM", "useGeometry": false}},
layers = '0',
data_format = 'filegdb',
out_path = './download')
The field I actually need to perform the WHERE clause on is a timestamp, to get the last 24 hours of data.
Solved! Go to Solution.
Hi Simon,
Could you try to put a pair of single quotation mark around JAM in your layerQueries?
This works for me in the rest endpoint, I guess it should work in the python code as well.
{ "0":{"where": "type= 'JAM'" }}
To be safe, I would specify the queryOption which was added in 10.2 according to the REST API document:
{ "0":{"queryOption":"useFilter", "where": "type= 'JAM'" }}
Hi Simon,
Could you try to put a pair of single quotation mark around JAM in your layerQueries?
This works for me in the rest endpoint, I guess it should work in the python code as well.
{ "0":{"where": "type= 'JAM'" }}
To be safe, I would specify the queryOption which was added in 10.2 according to the REST API document:
{ "0":{"queryOption":"useFilter", "where": "type= 'JAM'" }}
Hey Simo, hope things are good with you.
Too easy! Works a charm. Ashamed I didn't work that one out.
Now onto tweaking the expression to filter using dates.
Thanks.
replica = waze_flc.replicas.create(replica_name = 'Waze_Download',
layer_queries = {"0":{"queryOption": "useFilter", "where": "type = 'JAM'", "useGeometry": "false"}},
layers = '0',
data_format = 'filegdb',
out_path = './download')