PywpsTutorials

From PyWPS wiki

Jump to: navigation, search

Contents

[edit] Installation

[edit] Installing on Mac OS X

[edit] Kyng Chaos Packages version

Install this packages from Kyng Chaos web site:

  • frameworks: All Frameworks
  • GRASS: GRASS.app 6.3 CVS 070913 (should work even with other versions)

You natuarlly need Python >= 2.5 to make pyWPS work on Mac.

you can find it at :

osx python binaries packages

Install svn for mac osx :

Subversion osx binaries package

Download pywps source code from svn repository :

   svn checkout https://svn.wald.intevation.org/svn/pywps/branches/pywps-2.0

Rename it from "'trunk"' to '"pywps-2.0"' and copy the pywps-2.0 folder to :

   /Library/WebServer/CGI-Executables/pywps-2.0/

Make a temporary directory :

  mkdir /Library/WebServer/Documents/wps/wpsoutputs/

Give it the right permisions (read and write)


Install pywps into python libraries :

   cd /Library/WebServer/CGI-Executables/pywps-2.0
   python setup.py install
   ln -s /usr/bin/wps.py /usr/lib/cgi-bin/wps.py

[edit] configuration

Change the first line of the file :

/Library/WebServer/CGI-Executables/pywps-2.0/wps.py

   from :
   #!/usr/bin/python
   to :
   #!/usr/local/bin/python 

Setting up the pywps processes files (as example we'll setting up only the addvalue process) :

   Rename : /Library/WebServer/CGI-Executables/pywps-2.0/pywps/processes/__init__.py-dist : 
   from :
   __init__.py-dist
   to :  
   __init__.py


   Rename : /Library/WebServer/CGI-Executables/pywps-2.0/pywps/processes/addvalue.py-dist
   from :
   addvalue.py-dist
   to :
   addvalue.py


Comment the processeses that you don't need in the file :

/Library/WebServer/CGI-Executables/pywps-2.0/pywps/processes/__init__.py

it must be like :

   # Author:	Jachym Cepicky
   #		        http://les-ejk.cz
   __all__ = [ 
       "addvalue",
   #        "classify" ,
   #        "flow",
   #        "ndvi",
   #        "shortestpath", 
   #        "spearpath", 
   #        "visibility",
   #        "inputsoutputs",
   #        "buffer",
   #        "convert",
         	]


Change your /Library/WebServer/CGI-Executables/pywps-2.0/pywps/etc/settings.py file

to reflect your setting :


   WPS = {
      'version': "0.4.0",
      "debuglevel": 0,
      'ServiceIdentification': {
          'Title':"PyWPS 2.0.0",
          'ServiceType':"WPS",
         'ServiceTypeVersion':"1.0.0",
      },
      'ServiceProvider': {
               'ProviderName' : "SASHA",
               'IndividualName':"EPI",
               'PositionName':"UP",
               'Role':"UP",
               'DeliveryPoint': "Street ",
               'City': "City",
               'PostalCode':"000000",
               'Country': "Your Country",
               'ElectronicMailAddress':"massimodisasha@yahoo.it",
       },
      'OperationsMetadata': {
          'ServerAddress' : "http://localhost/cgi-bin/pywps-2.0.0-rc1/wps.py",
       },
  ServerSettings = {
      'outputPath': '/Library/WebServer/Documents/wps/wpsoutputs/',
      'outputUrl':  'http://localhost/wps/wpsoutputs',
      'tempPath': '/var/tmp',
      'maxOperations':1,
      'maxSize':5242880, # 5 MB
      'maxInputParamLength':1024,
   }


Change your /Library/WebServer/CGI-Executables/pywps-2.0/pywps/etc/grass.py file as follow :

   grassenv = {
   'PATH': "/Applications/GRASS-6.3.app/Contents/MacOS/bin/:/Applications/GRASS-6.3.app/Contents/MacOS/scripts/:/usr/local/bin/:/bin/:",
   'GRASS_ADDON_PATH': "",
   'GRASS_VERSION': "6.3.cvs",
   'GRASS_PERL': "/usr/bin/perl",
   'GRASS_GUI': "text",
   'GISBASE': "/Applications/GRASS-6.3.app/Contents/MacOS/",
   'LD_LIBRARY_PATH':"/Applications/GRASS-6.3.app/Contents/MacOS/lib/",
   'HOME':"/Library/WebServer/Documents",
   }

Remember to configure you Web server dir.

[edit] test

download a tif file (I've downloaded this) and call from command line:

 ./wps.py "service=WPS&version=0.4.0&identifier=addvalue&request=execute&datainputs=input,/Volumes/cache/geodata/sample.tif,value,250&status=false&store=true"

/Volumes/cache/geodata/sample.tif is naturally the path to your downloaded file.

the output file opened in QGIS should look like this: image:Picture-11.jpg

[edit] Compiling GRASS version

If you have a Grass-cvs installed from source, only changes from the previouse notes, are in the file :

/Library/WebServer/CGI-Executables/pywps-2.0/pywps/etc/grass.py

if you have Grass installed in a standard location (/usr/local/grass-6.3.cvs) the settings mus be like :


  grassenv = {
      'PATH': "/usr/local/grass-6.3.cvs/bin/:/usr/local/grass-6.3.cvs/scripts/:/usr/bin/:/bin/:",
      'GRASS_ADDON_PATH': "/Library/GRASS/6.3/Modules/bin/",
      'GRASS_VERSION': "6.3.cvs",
      'GRASS_PERL': "/usr/bin/perl",
      'GRASS_GUI': "text",
      'GISBASE': "/usr/local/grass-6.3.cvs",
      'LD_LIBRARY_PATH':"/usr/local/grass-6.3.cvs/lib",
      'HOME':"/Library/WebServer/Documents",
   }

Notes: Thanks to W.K., build grass from source on osx is really simple, just download the cvs files (see here ), and follow the osx notes, you can find it in : /grass6/macosx/ReadMe.rtf in it you have all the info on how to configure and build grass and its dependancies, plus usefool stuff.

Personal tools