Quick and dirty gis server

June 26, 2007

Here is a quick and dirty ArcGIS geoprocessing server. I mostly did this so that I can call ArcGIS routines from scripts on my linux box across a cluster of ArcGIS servers.

It is not without caveats, mostly security caveats. I work in a firewalled environment and would not recommend exposing the entire arcgisscripting geoprocessing object in a non-firewalled environment, without adding some security. With the client code I am able to write scripts that work on either Win32 or Linux with the same code.

Additionally, you will need to refer to files and directories in your scripts as they would appear to the server instance (with its windows permissions). As ArcGIS scripting routines do not directly allow the passing of GIS data to them, you will have to point to them on the server’s filesystem, geodatabase or remote ArcSDE server as you would locally on the server. Server:

from SimpleXMLRPCServer import SimpleXMLRPCServer
import arcgisscripting as agis
geop = agis.create()
server = SimpleXMLRPCServer(("",8000))
print "Starting server..."


import sys
print "We're running on: ", sys.platform
if sys.platform == "win32":  # We're on win32, call instance of gp object as we normally would.
        print "Importing the geoprocessing object"
        import arcgisscripting as agis
        gp = agis.create()
else:  # Run our calls over XMLRPC to REMOTE_SERVER
        from xmlrpclib import ServerProxy
        print "Using XMLRPC to connect to:", REMOTE_SERVER
        gp = ServerProxy(REMOTE_SERVER)
# Just check that we can call the geoprocessing object.
print gp.ProductInfo() #Show which product we're running just to make sure it is working.

Use: On the server run:

python server.py

Starting server...

On the client call the Client code at the top of your geoprocessing script, then refer to the gp object as you would normally.

comments powered by Disqus
Quick and dirty GIS Server - June 26, 2007 - Jonah Duckles