PyWPS – Project status and demo
ˇ
´
Jachym Cepick´ 1
y
1 Geosense

s.r.o. http://geosense.cz

WPS Workshop
Jachym Cepicky

Forester
OpenSource GIS developer (former
user) - GRASS, OpenLayers, PyWPS,
...
Member of Board of directors of Open
Source Geospatial Foundation
(OSGeo.org)
@jachymc http://les-ejk.cz
http://www.openstreetmap.org/user/jachymc
TOC

1

About PyWPS

2

Code

3

PyWPS 4
What is PyWPS

OGC WPS on the Server
Since 2006
Python
http://pywps.wald.intevation.org
http://github.org/geopython/pywps
PyWPS - what it is NOT

PyWPS is no analytical tool or engine. It does not perform
any type of geospatial calculation.
PyWPS is not special XML parser or generator. It does not
validate your GMLs against given schemas (yet), it does
not build GML from Python objects.
It is not complicated
PyWPS - what it is NOT

PyWPS is no analytical tool or engine. It does not perform
any type of geospatial calculation.
PyWPS is not special XML parser or generator. It does not
validate your GMLs against given schemas (yet), it does
not build GML from Python objects.
It is not complicated
PyWPS - what it is NOT

PyWPS is no analytical tool or engine. It does not perform
any type of geospatial calculation.
PyWPS is not special XML parser or generator. It does not
validate your GMLs against given schemas (yet), it does
not build GML from Python objects.
It is not complicated
Keywords
Keywords

rather bike, then a car
Keywords

#small
Keywords

#modular
Keywords

#fast
Keywords

#easy
Keywords

#slick
Keywords

#accessories (GRASS, GDAL, Shapely, #python)
History of PyWPS
2006-11-10 version 1.0.0 Web User Interface for WPS
(Embrio).
2007-10-08 version 2.0.0 New version improved stability,
Process class, OpenLayers 2.x.
2008-11-06 version 3.0.0 New code structure, implementation
of WPS 1.0.0
2009-06-01 version 3.1.0 New generic JavaScript WPS Client
library and more.
2011-09-06 version 3.2.0 MapServer
2013 Moved to GitHub
http://github.com/geopython/pywps
2013-5 FOSS4G-CEE 2013, Bucharest, Started to work
on PyWPS-4
How does it work
How does it work

Internet, sharing
How does it work
How does it work
How does it work
How does it work

One process
How does it work

Two processes
How does it work

Process chain
TOC

1

About PyWPS

2

Code

3

PyWPS 4
Talk is cheap. Show me the code

1 from pywps.Process import WPSProcess
2 from osgeo import ogr
3 import types
4 [...]
5
WPSProcess.__init__(self,
6
identifier = "ogrbuffer", # must be same, as filename
7
title="Buffer process using OGR")
8 [...]
9
self.data = self.addComplexInput(identifier = "data")
10
self.size = self.addLiteralInput(identifier="size")
11
self.output =self.addComplexOutput(identifier="buffer")
Talk is cheap. Show me the code

1 from pywps.Process import WPSProcess
2 from osgeo import ogr
3 import types
4 [...]
5
WPSProcess.__init__(self,
6
identifier = "ogrbuffer", # must be same, as filename
7
title="Buffer process using OGR")
8 [...]
9
self.data = self.addComplexInput(identifier = "data")
10
self.size = self.addLiteralInput(identifier="size")
11
self.output =self.addComplexOutput(identifier="buffer")
Talk is cheap. Show me the code

1 from pywps.Process import WPSProcess
2 from osgeo import ogr
3 import types
4 [...]
5
WPSProcess.__init__(self,
6
identifier = "ogrbuffer", # must be same, as filename
7
title="Buffer process using OGR")
8 [...]
9
self.data = self.addComplexInput(identifier = "data")
10
self.size = self.addLiteralInput(identifier="size")
11
self.output =self.addComplexOutput(identifier="buffer")
Talk is cheap. Show me the code
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31

def execute(self):
inSource = ogr.Open(self.data.getValue())
inLayer = inSource.GetLayer()
[...]
outLayer = outSource.CreateLayer(
out,None,ogr.wkbUnknown)
[...]

while index < featureCount:
self.status.set("Calculating buffer for feature %d from %d
(100*(index+1)/featureCount*1.0))
[...]
inGeometry = inFeature.GetGeometryRef()
# make the buffer
buff = inGeometry.Buffer(float(self.size.getValue()))
[...]
self.output.setValue(out)
return
Talk is cheap. Show me the code
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31

def execute(self):
inSource = ogr.Open(self.data.getValue())
inLayer = inSource.GetLayer()
[...]
outLayer = outSource.CreateLayer(
out,None,ogr.wkbUnknown)
[...]

while index < featureCount:
self.status.set("Calculating buffer for feature %d from %d
(100*(index+1)/featureCount*1.0))
[...]
inGeometry = inFeature.GetGeometryRef()
# make the buffer
buff = inGeometry.Buffer(float(self.size.getValue()))
[...]
self.output.setValue(out)
return
What can be connected

Python* (GDAL/OGR, GRASS, MapServer, Shapely, Fiona, R, PostGIS, . . . )
Jython - Java* (GeoTools, JTS, GeoServer, . . . )
Any batch file
Tools, which are tested with PyWPS

¨
GRASS (GRASS-WPS interface, Soren Gebert)
R
Taverna (WPS-WSDL orchestration, Jorge de Jesus)
MapServer (output generation using OGC OWS, still concept)
TOC

1 About PyWPS

2 Code

3 PyWPS 4
Bright future

Started from scratch
Use Python 2.7 (for future 3.0 migration)
Try different interpreters of Python (pypy)
Easy parsing with lxml
Prepare for next WPS version
Change of the whole process concept
PyWPS 4

#geopython 2006
PyWPS 4

#geopython 2013
lxml http://lxml.org
GRASS-WPS, GRASS-Python
Werkzeug http://werkzeug.pocoo.org/
Python 3
Django
MapServer for output generation
Respect to new OGC WPS 2.0.0 features
...
Happy processing!
jachym.cepicky@gmail.com
http://les-ejk.cz
@jachymc
http://github.org/jachym/pywps-4
http://pywps.wald.intevation.org

PyWPS at COST WPS Workshop

  • 1.
    PyWPS – Projectstatus and demo ˇ ´ Jachym Cepick´ 1 y 1 Geosense s.r.o. http://geosense.cz WPS Workshop
  • 2.
    Jachym Cepicky Forester OpenSource GISdeveloper (former user) - GRASS, OpenLayers, PyWPS, ... Member of Board of directors of Open Source Geospatial Foundation (OSGeo.org) @jachymc http://les-ejk.cz http://www.openstreetmap.org/user/jachymc
  • 3.
  • 4.
    What is PyWPS OGCWPS on the Server Since 2006 Python http://pywps.wald.intevation.org http://github.org/geopython/pywps
  • 5.
    PyWPS - whatit is NOT PyWPS is no analytical tool or engine. It does not perform any type of geospatial calculation. PyWPS is not special XML parser or generator. It does not validate your GMLs against given schemas (yet), it does not build GML from Python objects. It is not complicated
  • 6.
    PyWPS - whatit is NOT PyWPS is no analytical tool or engine. It does not perform any type of geospatial calculation. PyWPS is not special XML parser or generator. It does not validate your GMLs against given schemas (yet), it does not build GML from Python objects. It is not complicated
  • 7.
    PyWPS - whatit is NOT PyWPS is no analytical tool or engine. It does not perform any type of geospatial calculation. PyWPS is not special XML parser or generator. It does not validate your GMLs against given schemas (yet), it does not build GML from Python objects. It is not complicated
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
    History of PyWPS 2006-11-10version 1.0.0 Web User Interface for WPS (Embrio). 2007-10-08 version 2.0.0 New version improved stability, Process class, OpenLayers 2.x. 2008-11-06 version 3.0.0 New code structure, implementation of WPS 1.0.0 2009-06-01 version 3.1.0 New generic JavaScript WPS Client library and more. 2011-09-06 version 3.2.0 MapServer 2013 Moved to GitHub http://github.com/geopython/pywps 2013-5 FOSS4G-CEE 2013, Bucharest, Started to work on PyWPS-4
  • 17.
  • 18.
    How does itwork Internet, sharing
  • 19.
  • 20.
  • 21.
  • 22.
    How does itwork One process
  • 23.
    How does itwork Two processes
  • 24.
    How does itwork Process chain
  • 25.
  • 26.
    Talk is cheap.Show me the code 1 from pywps.Process import WPSProcess 2 from osgeo import ogr 3 import types 4 [...] 5 WPSProcess.__init__(self, 6 identifier = "ogrbuffer", # must be same, as filename 7 title="Buffer process using OGR") 8 [...] 9 self.data = self.addComplexInput(identifier = "data") 10 self.size = self.addLiteralInput(identifier="size") 11 self.output =self.addComplexOutput(identifier="buffer")
  • 27.
    Talk is cheap.Show me the code 1 from pywps.Process import WPSProcess 2 from osgeo import ogr 3 import types 4 [...] 5 WPSProcess.__init__(self, 6 identifier = "ogrbuffer", # must be same, as filename 7 title="Buffer process using OGR") 8 [...] 9 self.data = self.addComplexInput(identifier = "data") 10 self.size = self.addLiteralInput(identifier="size") 11 self.output =self.addComplexOutput(identifier="buffer")
  • 28.
    Talk is cheap.Show me the code 1 from pywps.Process import WPSProcess 2 from osgeo import ogr 3 import types 4 [...] 5 WPSProcess.__init__(self, 6 identifier = "ogrbuffer", # must be same, as filename 7 title="Buffer process using OGR") 8 [...] 9 self.data = self.addComplexInput(identifier = "data") 10 self.size = self.addLiteralInput(identifier="size") 11 self.output =self.addComplexOutput(identifier="buffer")
  • 29.
    Talk is cheap.Show me the code 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 def execute(self): inSource = ogr.Open(self.data.getValue()) inLayer = inSource.GetLayer() [...] outLayer = outSource.CreateLayer( out,None,ogr.wkbUnknown) [...] while index < featureCount: self.status.set("Calculating buffer for feature %d from %d (100*(index+1)/featureCount*1.0)) [...] inGeometry = inFeature.GetGeometryRef() # make the buffer buff = inGeometry.Buffer(float(self.size.getValue())) [...] self.output.setValue(out) return
  • 30.
    Talk is cheap.Show me the code 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 def execute(self): inSource = ogr.Open(self.data.getValue()) inLayer = inSource.GetLayer() [...] outLayer = outSource.CreateLayer( out,None,ogr.wkbUnknown) [...] while index < featureCount: self.status.set("Calculating buffer for feature %d from %d (100*(index+1)/featureCount*1.0)) [...] inGeometry = inFeature.GetGeometryRef() # make the buffer buff = inGeometry.Buffer(float(self.size.getValue())) [...] self.output.setValue(out) return
  • 31.
    What can beconnected Python* (GDAL/OGR, GRASS, MapServer, Shapely, Fiona, R, PostGIS, . . . ) Jython - Java* (GeoTools, JTS, GeoServer, . . . ) Any batch file
  • 32.
    Tools, which aretested with PyWPS ¨ GRASS (GRASS-WPS interface, Soren Gebert) R Taverna (WPS-WSDL orchestration, Jorge de Jesus) MapServer (output generation using OGC OWS, still concept)
  • 33.
    TOC 1 About PyWPS 2Code 3 PyWPS 4
  • 34.
    Bright future Started fromscratch Use Python 2.7 (for future 3.0 migration) Try different interpreters of Python (pypy) Easy parsing with lxml Prepare for next WPS version Change of the whole process concept
  • 35.
  • 36.
  • 37.
    lxml http://lxml.org GRASS-WPS, GRASS-Python Werkzeughttp://werkzeug.pocoo.org/ Python 3 Django MapServer for output generation Respect to new OGC WPS 2.0.0 features ...
  • 38.