I'm wondering if it's possible to create a script that loops through an ArcGIS Server REST API query in order to retrieve all features contained within the layer?
For example, I have a query created that returns the expected results, but it only returns 1000 records...the default value set when publishing the service. Is it possible to loop through the next 1000 records, and the next 1000 records after that until I have all the features within that layer?
Thanks in advance!
Hi Matt,
I wrote a module that can do this, I sent you a message on LinkedIn asking for your email so I can send it to you.
Caleb
In case anyone else comes across this post, the get_all=True has been updated to exceed_limit=True on line 12 of the code Caleb posted.
Just wanted to add here I have some working code to do this. I have posted a python package on GitHub. It can export web map layers to feature classes, and keep querying features until it gets them all if the features exceed the query limit. Some sample code (package requires the requests module):
import restapi url = 'http://some_server.com/arcgis/rest/services/folder/some_map_service/MapService' # only use username and password if service is secured user= 'username' pw = 'password' service = restapi.MapService(url, user, pw) # export parcels layer shp = r'C:\TEMP\output_parcels.shp' service.layer_to_fc('parcels', shp, get_all=True) # setting the get_all parameter to true will allow you to exceed the transfer limit
The help documentation is available here, or you can get at it from the module:
restapi.getHelp() # launch web help