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'm thinking it should be possible to consume an ESRI Geoprocessing service from a python script without invoking ArcPy or needing an ESRI installation on the client machine. For example I create a geoprocessing service that takes a series of point location and returns a csv file with the values under them as a file. I would like to include this service call in a python client application that will be running on machines that don't have any ESRI installation. Couldn't you create the rest call to kick off the service and consume the result without arcpy?

Does anyone have an example of how you might do this?

Thanks, Colin

share|improve this question

3 Answers 3

ArcGIS for Server will give you JSON over HTTP. Python has HTTP client stuff built in (urllib, etc) and better community packages (Requests, httplib2). And JSON and Python go together like chips and salsa.

share|improve this answer
    
I've done stuff with urllib and owslib in Python so I can see how that might go together. I'll look into how to deserialize the JSON response. I quess I was most befuddled by how to structure the rest response with things like model parameters, specifying inputs from the client file system, etc. –  Colin Talbert Jul 12 '12 at 18:21
    
To send a post request to an ESRI geocoder service, I am using the Python Requests module like this: r = requests.post(geocoderUri, params={"addresses":payload, "f":"json", "outSR":4326}) The payload var contains the json object that encodes the address data in the format that the service is expecting. –  DavidF Jul 11 at 21:08

For structuring the rest response, it may help to look at how the javascript API interacts with geoprocessing services using Firebug in Firefox. Typically all the parameters are either bare or in some JSON object and are appended to the url's query string (or sent via POST request) in an UrlEncoded format. Then you just need to parse the returned JSON results which you acquire by the f=json flag in the request.

share|improve this answer

Esri have published what they call the GeoServices REST Specification which can be accessed from here.

It contains a lot of the detail about the REST communication and is the foundation on which ArcGIS Server is based. This gives a lot of detail about the request and response structures for each of the service types. Section 6.0 (page 52) is the section dealing with the GP Service, perhaps this will help shed some light on how you should structure your requests.

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.