project logo OSGeo Labs

PyWPS Quickstart

PyWPS is an OGC WPS server implementation written in Python.

PyWPS allows for the expose geospatial operations (refered as processes).

PyWPS is Open Source, released under an GNU/GPL license, and runs on all major platforms (Windows, Linux, Mac OS X).

PyWPS is installed by default on the OSGeo-Live DVD. This QuickStart will describe how to:

  • perform a fresh installation of PyWPS
  • test PyWPS installation
  • basic configuration of PyWPS instance
  • create and deploy process in PyWPS
  • perform GetCapabilities, DescribeProcess and Execute operations

Installation

System Requirements

PyWPS is written in Python, and works with (tested) version 2.6 and 2.7

PyWPS requires the following supporting libraries:

  • lxml (version >= 2.2.3) for XML support

Installing from Source

Download pywps the latest version or clone from GitHub:

$ git clone https://github.com/geopython/PyWPS.git pywps

Ensure that CGI is enabled for your install directory.

Tester Application

To run the PyWPS tester, use the PyWPS launcher from the Web Services group, or open Firefox and navigate to http://localhost/cgi-bin/pywps:

From Application menu, start Terminal application and test GetCapabilities operation:

$ wget -O - "http://localhost/cgi-bin/pywps?service=wps&request=GetCapabilities"

<wps:Capabilities service="WPS"
...
</wps:Capabilities>

You should see full WPS Capabilites response document. You can also see similar response using browser

Select some process from the list, for example ultimatequestionprocess, and display it’s description by calling DescribeProcess operation.:

$ wget -O - "http://localhost/cgi-bin/pywps?service=wps&version=1.0.0&request=DescribeProcess&identifier=ultimatequestionprocess"

<wps:ProcessDescriptions
...
</wps:ProcessDescriptions>

Again, you should see WPS DescribeProcess response document. You can also see similar response using browser

Now let us Execute ultimatequestionprocess, on the server. The process is, according to it’s description, able to Answer to Life, the Universe and Everything. No inputs are requied.:

$ wget -O - "http://localhost/cgi-bin/pywps?service=wps&version=1.0.0&request=Execute&identifier=ultimatequestionprocess"

# wait about 10s

<wps:ExecuteResponse
...
     <wps:Data>
            <wps:LiteralData dataType="integer">42</wps:LiteralData>
    </wps:Data>
...
</wps:ExecuteResponse>

As you might know, it takes a while, before the process is calculated. In our case, it’s about 10s. At the and, we can see the answer to life, universe and everyting.

Configuration

You can configure PyWPS instance in the /usr/local/share/pywps/pywps.cfg configuration file. The values are self explaining, but you can always refer to standard documentation

Processes

You can find some example processes in the /usr/local/share/pywps/processes directory. Every process is usually stored in separate file and is represented by Python class, with constructor and execute() method:

# Example of PyWPS process (shorten)
from pywps.Process import WPSProcess
class Process(WPSProcess):
 def __init__(self):
     WPSProcess.__init__(self,
                         identifier="ultimatequestionprocess", #the same as the file name
                         ....

 def execute(self):
     import time
     self.status.set("Preparing....", 0)
     for i in xrange(1, 11):
         time.sleep(2)
         self.status.set("Thinking.....", i*10)
     #The final answer
     self.Answer.setValue("42")

Directory of your process deployment is configured in pywps file within the cgi-bin directory, in the PYWPS_PROCESSES environment variable.

For more information on pywps, please consult the documentation on the pywps website.

Copyright & Disclaimer