Ticket #2 (new enhancement)

Opened 11 years ago

GIS GRASS integration

Reported by: soeren Owned by: soeren
Priority: major Milestone:
Component: zoo-kernel Version: 1.0
Keywords: Cc: soeren


I have implemented a proof of concept to attach GIS GRASS as processing back-end to ZOO WPS. The approach is quite generic. There is (hopefully) no need to implement a single line of code to attach a grass module as WPS service. Everything is automatically generated and works with grass7.

The principle:

Based on the grass module WPS XML description [0], which must be generated for the module in gis grass7, a zcfg file and a python service file are generated. The generator is available here [1]. There is also a grass XML WPS to YAML generator available for future use [2].

The zcfg file should work out of the box, but it can of course be modified to your needs.

Automatically generated python service file example for v.voronoi:

import ZOO_Project.ZOOGrassModuleStarter as zoo
def v_voronoi(m, inputs, outputs):
    service = zoo.ZOOGrassModuleStarter()
    service.fromMaps("v.voronoi", inputs, outputs)

    return 1

How it works?

The generated python service file instantiates an object of the class ZOOGrassModuleStarter [3], passing the input and output maps. This class is derived from GrassModuleStarter? [4], which is a framework to start gis grass modules based on external data.

The ZOOGrassModuleStarter will write the input data located in the input map to a temporary directory, so grass can import/link it. Then a gis grass location based on the first input is generated. Then the grass module will be executed and the result will be exported and written into the output map, so the zoo kernel can handle it.

What to modify?

To get the ZOOGrassModuleStarter to work properly, some paths must be set in the header section. This is an "works for me" example:

# !!!!! EDIT THIS SECTION !!!!!
# Some default variables. Override them to your needs.
# !!!!! END EDIT SECTION !!!!!

These settings are used by all automatically generated grass python services. They may change in future!

Example installation:

I have attached a tar.gz archive containing the Python code of the ZOOGrassModuleStarter frame-work and sample zcfg files + service python files. Just copy the content into your cgi directory, modify the main.cfg and the ZOOGrassModuleStarter.py in ZOO_Project and install PyXB [5]. Python 2.6, PyXB and a valid grass7 installation are the only dependencies.

The simple grass modules r.add, r.mult, r.div and r.sub are available here [6]. Thy are not part o grass7.


  • The zcfg files may contain letters which are not supported or wrongly interpreted by the zoo kernel. This is related to parameter descriptions of grass modules, which make use of .,/() and so on.
  • ZOO kernel automatically sets obligatorily variables, even if no default value is specified. I will report this in a different ticket.

Enjoy and good Luck

[0] http://grass.osgeo.org/wiki/WPS

[1] http://code.google.com/p/vtk-grass-bridge/source/browse/trunk/WPS/ZOO_Project/GrassXMLtoZCFG.py

[2] http://code.google.com/p/vtk-grass-bridge/source/browse/trunk/WPS/ZOO_Project/GrassXMLtoYAML.py

[3] http://code.google.com/p/vtk-grass-bridge/source/browse/trunk/WPS/ZOO_Project/ZOOGrassModuleStarter.py

[4] http://code.google.com/p/vtk-grass-bridge/source/browse/trunk/WPS/GrassModuleStarter.py

[5] http://pyxb.sourceforge.net/

[6] http://code.google.com/p/vtk-grass-bridge/source/browse/#svn/trunk/WPS/Testing/Python/GrassAddons

Attachments (1)

ZOO_GRASS_cgi_content.tar.gz (170.2 KB) - added by soeren 11 years ago.

Download all attachments as: .zip

Change History

Changed 11 years ago by soeren

Note: See TracTickets for help on using tickets.


Context Navigation

ZOO Sponsors

http://www.zoo-project.org/trac/chrome/site/img/geolabs-logo.pnghttp://www.zoo-project.org/trac/chrome/site/img/neogeo-logo.png http://www.zoo-project.org/trac/chrome/site/img/apptech-logo.png http://www.zoo-project.org/trac/chrome/site/img/3liz-logo.png http://www.zoo-project.org/trac/chrome/site/img/gateway-logo.png

Become a sponsor !

Knowledge partners

http://www.zoo-project.org/trac/chrome/site/img/ocu-logo.png http://www.zoo-project.org/trac/chrome/site/img/gucas-logo.png http://www.zoo-project.org/trac/chrome/site/img/polimi-logo.png http://www.zoo-project.org/trac/chrome/site/img/fem-logo.png http://www.zoo-project.org/trac/chrome/site/img/supsi-logo.png http://www.zoo-project.org/trac/chrome/site/img/cumtb-logo.png

Become a knowledge partner

Related links

http://zoo-project.org/img/ogclogo.png http://zoo-project.org/img/osgeologo.png