[GRASS-dev] Python script to call grass 7 modules as service

Soeren Gebbert soerengebbert at googlemail.com
Sun Jan 3 09:17:58 EST 2010


Dear developers,
JFYI:
I have implemented a Python script which allows to call grass 7
modules as a service (e.g.: from a WPS server).
This script works currently only with grass raster modules. Vector
modules are work in progress. The processing is based
on grass version 7.
The clue is that the user provides the name of the module, some
parameters and the input data as png or geotiff files and receives
geotiff or gml files as output.
All the location/mapset creation as well as the import and export is
done automatically by the script. The coordinate system of the
first input file is used to create the grass work location. Next
features is, that all the input files are linked via r.external into
the grass
work location. No explicit import is needed. Currently the output is
exported via r.out.gdal and v.out.ogr,
but r.external.out will be used in the future, so that raster data
will be processed via gdla access without import or export (thanks to
Glynn and Frank!).

The Python script (some parts are based on pyWPS from Jachym Cepicky):
http://code.google.com/p/vtk-grass-bridge/source/browse/trunk/WPS/GrassModuleStarter.py

Example input files:
http://code.google.com/p/vtk-grass-bridge/source/browse/trunk/WPS/Testing/Python/r.contour_input.txt
http://code.google.com/p/vtk-grass-bridge/source/browse/trunk/WPS/Testing/Python/r.watershed_input.txt

I hope this script will simplify the use of grass as WPS server back-end.

The script is still under development and provides only basic features.
Better error and message handling is needed, as well as vector support
and testing.

Any comments, suggestions, criticism are welcome. :)

Have fun
Soeren


More information about the grass-dev mailing list