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.

To install the servlet, go into the wps directory of the svn tree and type

ant build

Next, go to the tomcat administrator, and deploy the war file that was created in directory wps/dist

Setting up R and the Rserve process

We assume that R is somehow installed on your machine. The commands below worked on a linux machine running debian etch and lenny, using the bash shell. It is not required but maybe also not a bad idea to run Rserve as a different user, and we will assume user rserve (in case of problems, less damage can be done). We assume that the home directory of this user is /home/rserve.

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, e.g.

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).

Installing the astonGeostats package

the psgp method available from the astonGeostats package (also in the svn tree on sourceforge) is dependent on the it++ libraries, and is therefore kept separately from the main intamap package. If you have it++ installed on your computer (on ubuntu/debian: apt-get install itpp-dev), then you can compile it, in the directory where the package resides:

R CMD build astonGeostats
R_LIBS=~/Rlibs R CMD INSTALL astonGeostats_x.y-z.tar.gz

with x,y and z the appropriate version numbers that the first command will reveal. In this case, you also have to modify .First, as .First=function(){

 library(astonGeostats)
 library(intamap)

} save.image()

Installing the spatialCopula package

package spatialCopula is, at time of writing this (Mar 2009) not included in intamap, and not publicly released. If you want it, please ask us.

Creating the time calibration data

Some of the methods in R package intamap are very time demanding, notably the spatialCopula method. Otherwise, huge amounts of data will also be time demanding. To take maximum available time into account when automatically selecting an appropriate interpolation method, the computer on which the wps will run needs to find out how fast it is. This is done by the time calibration step. It takes a few hours, but only has to be done once. If it is not done, maximum time in a wps request has to be ignored.

Start R in the directory where the Rserve process will also be started. Available packages should now be loaded automatically (see steps above). Create the timeModels by

timeModels = generateTimeModels()

and exit R while saving the timeModels:

q('yes')

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 -s9 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

There is now a java client that runs all (100+) tests automatically. Run it in directory wps/examples

mkdir Responses
java -jar wps-client.jar -url URL -r Requests Responses

with URL the appropriate url to the wps.