Working with Web Processing Service with Python and OWSLib

In this notebook, you will interact with a Web Processing Service (WPS) server using the OWSLib library, a client for OGC Web Services. More specifically, you’ll learn how to list available processes, get information about a process, and execute a process. If you need more information than provided here, refer to the OWSLib documentation.

Connect to server and list processes

Here is how to establish a connection to a WPS server and list the available processes. We first connect to the server, then send a getCapabilities request to the server, which answers with a list of all the processes it hosts. This allows the client to populate its processes attribute.

from owslib.wps import WebProcessingService

# Connect to the server
wps = WebProcessingService('')


# Send a `getCapabilities` request to populate the list of processes

# Print out the identifiers and abstract of five processes
for process in wps.processes[:5]:
    print(f"{process.identifier} \t : {process.abstract} \n")
humidex 	 : The humidex indicates how hot the air feels to an average person, accounting for the effect of humidity. It can be loosely interpreted as the equivalent perceived temperature when the air is dry. 

heat_index 	 : Perceived temperature after relative humidity is taken into account ([Blazejczyk2012]_). The index is only valid for temperatures above 20degC. 

tg 	 : We assume a symmetrical distribution for the temperature and retrieve the average value as Tg = (Tx + Tn) / 2 

wind_speed_from_vector 	 : Computes the magnitude and angle of the wind vector from its northward and eastward components, following the meteorological convention that sets calm wind to a direction of 0deg and northerly wind to 360deg. 

wind_vector_from_speed 	 : Compute the eastward and northward wind components from the wind speed and direction. 

Get information about a single process

Assume we’re interested in using the humidex process, we first need to know which arguments this process expects. To get this information, we must first send a describeProcess request to the server for the process description.

process = wps.describeprocess('humidex')
print(process.title, " : ", process.abstract)
print ([x.identifier for x in process.dataInputs])
Humidex index.  :  The humidex indicates how hot the air feels to an average person, accounting for the effect of humidity. It can be loosely interpreted as the equivalent perceived temperature when the air is dry.
['tas', 'tdps', 'hurs', 'check_missing', 'missing_options', 'cf_compliance', 'data_validation', 'variable', 'output_name', 'output_format', 'csv_precision']

Each process has a list of dataInput objects, each with an individual title and abstract, a list of supported data types, constraints on the minimum and maximum of values it can take, and optionally a default value. For example, the tas argument is mandatory (minOccurs is set to 1).

tas = process.dataInputs[0]
NetCDF Files or archive (tar/zip) containing netCDF files. Mean surface temperature.

Similarly, each process’ has a list of processOutput object with descriptive fields, in addition to methods to retrieve the actual data from the server once the process has been executed.

from owslib.wps import ComplexDataInput

url = ""

exec = wps.execute("tg_mean", inputs=[
         ("tas", ComplexDataInput(url)),
         ("data_validation", "log")],


Retrieving the execution results

In synchronous mode, once the execution has completed the client automatically fetches the response. The response is an XML document that either stores the results, or links to the results, depending on how the process and server are configured.

from lxml import etree

<wps:ExecuteResponse xmlns:wps="" xmlns:ows="" xmlns:xlink="" xmlns:xsi="" xsi:schemaLocation=" ../wpsExecute_response.xsd" service="WPS" version="1.0.0" xml:lang="en-US" serviceInstance="http://localhost:5000/wps?request=GetCapabilities&amp;amp;service=WPS" statusLocation="">
    <wps:Process wps:processVersion="0.1">
        <ows:Title>Mean of daily average temperature.</ows:Title>
        <ows:Abstract>Resample the original daily mean temperature series by taking the mean over each period.</ows:Abstract>
    <wps:Status creationTime="2024-05-09T17:41:11Z">
        <wps:ProcessSucceeded>PyWPS Process Mean of daily average temperature. finished</wps:ProcessSucceeded>
            <ows:Abstract>The format depends on the 'output_format' input parameter.</ows:Abstract>
            <wps:Reference href="" mimeType="application/x-netcdf" encoding="base64" schema=""/>
            <ows:Title>Logging information</ows:Title>
            <ows:Abstract>Collected logs during process run.</ows:Abstract>
            <wps:Reference href="" mimeType="text/plain" encoding="" schema=""/>
            <ows:Title>Link to all output files</ows:Title>
            <ows:Abstract>Metalink file storing all references to output files.</ows:Abstract>
                    <wps:ComplexData mimeType="application/metalink+xml; version=4.0" encoding="" schema="metalink/4.0/metalink4.xsd">&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;metalink xmlns="urn:ietf:params:xml:ns:metalink"&gt;

    &lt;file name=""&gt;
        &lt;metaurl mediatype="application/x-netcdf"&gt;;/metaurl&gt;
        &lt;publisher name="Finch" url="http://localhost:5000/wps"/&gt;


In the case of the tg_mean process, the results are stored in a netCDF file, which is returned as a ComplexDataOutput object. It is stored on the server, so the response only contains the URL to this output file.

out = exec.processOutputs[0]

# The link to the output stored on the server

You may retrieve the data directly with out.retrieveData(), in the case above you’ll get the bytes of the netCDF result file, or save the results to a file on disk using exec.getOutput(out.identifier, filepath="path/to/file").