Setting up the WPS

From Intamap

Contents

Setting up the java wps

On our test servers, we've used java 6 (which is 1.6, jre+jdk) and tomcat 5.5. The UU test server runs debian etch (4.0) linux, and got java 6 from backports. In principle you could compile for java 5.

[what should one do with the code/jars that are on svn to get the wps running?]

Setting up R and the Rserve process

We assume that R is somehow installed on your machine. They worked on a linux machine running debian etch, using the bash shell.

Installing the R intamap package

It is useful when you understand how R packages can be installed, and loaded. The steps below just outline one possible way of doing this that does not need root access. All steps below are assumed to be started from the same working directory.

Create a directory

mkdir ~/Rlibs

and start R with the command

R_LIBS=~/Rlibs R

This will make sure that packages that we subsequently install will end up in this directory.

On the R prompt, install a number of packages, by giving the following command on the R prompt. It will prompt for a CRAN repository mirror the first time it is issued.

install.packages(c("sp", "akima", "gstat", "rgdal"))

Next, try to install packages intamap and automap from CRAN by

install.packages(c("intamap", "automap"))

In case the last command does not work (... is not available), because intamap is not (yet) on CRAN, install it from source. Say the file is called intamap_0.2-11.tar.gz then install from the shell prompt by

R_LIBS=~/Rlibs R CMD INSTALL intamap_0.2-11.tar.gz

and do the same for package automap. To check everything works, start R as follows:

R_LIBS=~/Rlibs R --vanilla

and type

library(intamap)

this should give no errors, and output that resembles:

> library(intamap)
Loading required package: sp
Loading required package: gstat
Loading required package: rgdal
Geospatial Data Abstraction Library extensions to R successfully loaded
Loaded GDAL runtime: GDAL 1.4.0.0, released 2007/01/02
GDAL_DATA: Rlibs/rgdal/gdal
Loaded PROJ.4 runtime: Rel. 4.4.9, 29 Oct 2004
PROJ_LIB: Rlibs/rgdal/proj
Loading required package: akima
Loading required package: automap

If all libraries are installed, we need to configure R (or Rserve) such that when it starts, it by defaults loads package intamap and its dependencies. Start R from the directory where Rserve will always be started. Then type the R command

.First=function(){library(intamap)}
save.image()

this will create a .RData file in the current directory, with a .First function that will be called for every R process started in this directory (unless --vanilla is added).

Setting up Rserve and running it

The wps connects to R using Rserve, which is available from CRAN. First we need to install Rserve. We'll do this from CRAN. Start R with

R_LIBS=~/Rlibs R

and on the R prompt, install Rserve by

install.packages("Rserve")

Next, Rserve can be started, in daemon mode, by

rm -f nohup.out
R_LIBS=~/Rlibs nohup R CMD Rserve --no-save &

the output (normal console output) of this file will be written to the file nohup.out. After starting Rserve, this file is viewed by

cat nohup.out

and should look something like:

R version 2.8.0 (2008-10-20)
Copyright (C) 2008 The R Foundation for Statistical Computing
ISBN 3-900051-07-0

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

[Previously saved workspace restored]

Loading required package: sp
Loading required package: gstat
Loading required package: rgdal
Geospatial Data Abstraction Library extensions to R successfully loaded
Loaded GDAL runtime: GDAL 1.4.0.0, released 2007/01/02
GDAL_DATA: /home/rserve/Rlibs/rgdal/gdal
Loaded PROJ.4 runtime: Rel. 4.4.9, 29 Oct 2004
PROJ_LIB: /home/rserve/Rlibs/rgdal/proj
Loading required package: akima
Loading required package: automap
Rserv started in daemon mode.

Maintainance

If you need to stop Rserve, e.g. because you need it to load a newer version of some package, kill it first with

killall Rserve

When R runs on a different server from the wps server

When R runs on a different server from the wps server you need to configure Rserve such that it accepts connections from the machine on which the wps runs. See the Rserve documentation how to do this, under section configuration.

Testing the WPS

To test the WPS you can use the supplied test application which can be found at the following URL:

http://<server_address>:<server_port>/intamap/test.html

In here you need to supply the URL of the server (http://<server_address>:<server_port>/intamap/WebProcessingService) and paste a sample request into the box provided. Upon hitting submit, you will be presented with the prediction report.


Another way testing the WPS is to use wget. The following command sends the request "RequestExample1.xml" to the WPS and saves the response in a document called "response.xml". Aditionally the programm notifications of wget are logged in the "wget.log" file instead of being displayed in the console.

wget --append-output=wget.log --output-document=response.xml --post-file=ExampleRequest1.xml
"http://<server_address>:<server_port>/intamap/WebProcessingService"

There is also a zipped wget version for Windows which can be found under: http://gnuwin32.sourceforge.net/packages/wget.htm