Jump to: navigation, search

WPS

OGC WPS

The OpenGIS® Web Processing Service (WPS) Interface Standard provides rules for standardizing how inputs and outputs (requests and responses) for geospatial processing services, such as polygon overlay. The standard also defines how a client can request the execution of a process, and how the output from the process is handled. It defines an interface that facilitates the publishing of geospatial processes and clients’ discovery of and binding to those processes. The data required by the WPS can be delivered across a network or they can be available at the server.

Installation WPS service from 52°North

One of the WPS implementation service are from 52°North 52°North.

  • Download the latest 52°North WPS release from here.(If you want the source code, follow this tutorial)
  • Rename the downloaded .war file to wps.war and drop it in the webapps folder of your tomcat.

Configure R

  • Start R, install the package Rserve and the recommended ones with the following command. Add more of them for your own purposes:
install.packages(c("Rserve","sp","maptools","rgdal", "spatstat","gstat","automap"))

Optional

You can use the Rprofile.site file in directory R_HOME%/etc to configure options and packages that should be available on every start of R. To do this, initialize the .First function. Specify required libraries and the default work directory inside the function. These settings will be preloaded during start-up of R:

.First = function() {
#the following libraries will be loaded on R start-up:
library(sp)
library(gstat)
library(rgdal)
library(spatstat)
library(maptools)
library(automap)
#specify the R work directory here:
setwd("<R WD>") # change it!!
}

Configure Rserve

You can start Rserve from within R on your local machine by the following commands:

library(Rserve)
Rserve()

In that case you have to pass that parameter in the args argument such as:

Rserve(args="--no-save")

However, Rserve is a stand-alone program, so it can be started directly as well. If you installed Rserve from a source package (on unix), type:

R CMD Rserve

or

sudo R CMD Rserve --gui-none --RS-port 26311

N.B.1: This starts a daemon. N.B.2: This is the port Java code uses. Any unique and free port can be used.On Mac OS X, you might have this error:

/Library/Frameworks/R.framework/Resources/bin/Rcmd: line 62: exec: Rserve: not found

If that happens:

sudo cp /Library/Frameworks/R.framework/Resources/library/Rserve/libs/x86_64/Rserve-bin.so \
/Library/Frameworks/R.framework/Resources/bin/Rserve

Depending on the purpose and libraries on your computer you may want to add --gui-none or --no-save (see R documentation). Rserve passes any parameters to the underlying R engine except for Rserver-related parameters. After initialization Rserve daemonizes itself to work as a server. It can be shut down gracefully (i.e. it will wait until all existing connections are finished) if it recieves shutdown command from an authorized connection. It terminates not so gracefully if it receives usual termination signals.If no config file is supplied, Rserve accepts no remote connections, requires no authentication and file transfer is enabled. For more details about how to configure Rserve, see here.

Command line arguments

Starting with Rserve 0.1-9 special command line arguments are supported in addition to the config file. Normally Rserve passes all arguments to R, but several special ones are processed and removed from the list before initializing R. Those parameters override any settings specified in the config file.

  • --RS-port port Rserve will listen on the specified TCP port.
  • --RS-socket socket use the specified local unix socket instead of TCP/IP.
  • --RS-workdir path set working directory root for connections to the specified path.
  • --RS-conf file load the specified config file (the default config file is still loaded, but its settings have lower priority).
  • --RS-dumplimit n (debug version of Rserve only) specifies the number of values to print when dumping content of packages or SEXPs (default is 128).
  • --RS-settings print current settings of the Rserve. Useful to check the current configuration.
  • --RS-encoding encoding set default string encoding to the given value
  • --help prints a brief help screen and exits (R is not started)
  • --version prints version of Rserve.

This argument is retained in the list and processed by R as well.In order to list all currently supported arguments, type:

R CMD Rserve --help

Configuration

Rserve is configured by the configuration file R_HOME_DIR/etc/Rserv.conf (can be changed at compile time by specifying -DCONFIG_FILE=..). Additional configuration files can be added by the --RS-conf command line argument. The possible configuration entries are as follows (all entries are optional; default values are in angled brackets):

workdir <path> [/tmp/Rserv]
pwdfile <file> [none=disabled]
remote enable|disable [disable]
auth required|disable [disable]
plaintext enable|disable [disable]
fileio enable|disable [enable]
interactive yes|no [yes] (since 0.6-2)

(since version 0.1-9):

socket <socket> [none=disabled]
port <port> [6311]
maxinbuf <size in kb> [262144]

(since version 0.3):

maxsendbuf <size in kb> [0=unlimited]
uid <uid> [none]
gid <gid> [none]su now|server|client [none]

(since 0.6-1)(since version 0.3-16):

source <file>
eval <expressions>

(since version 0.5 and unix only):

chroot <directory> [none]
sockmod <mode> [0=default]
umask <mask> [0]

(since version 0.5-3):

encoding native|utf8|latin1 [native]

The password file (pwdfile) contains a list of Rserve usernames and passwords, with one username and password per line. The Rserve usernames have no relationship to the users on the machine where the Rserve is running. If you want to connect to an Rserver as Rserve user "stian", there does not need to be a user "stian" on the Rserve machine. If there is a user "stian" on the Rserve machine, then connecting via the Rserver as "stian" will not give any R scripts run by the Rserve user any additional access to files. A password file will look something like:

alanw frog
stian fishsoup

This would allow access to Rserve with the username alanw and password frog.


To check if you have an Rserve installed and running on a particular machine, you can run the command

telnet themachine theport

For example,

telnet localhost 6311

If you have an accessible Rserve, then you should see a response such as:

Connected to localhost.
Escape character is '^]'.
Rsrv0103QAP1

If you get a connection refused, then the Rserve is not running or cannot be accessed.

It can be started directly as well:

R CMD Rserve --RS-conf R_HOME_DIR/etc/Rserv.conf

Check R and Rserve connection

To check a connection between R and Rserve is possible to execute this script in R

#install.package("Rserve")
library(Rserve)
c=RSconnect(host = "<host>", port = <port>)
RSlogin(c, "<user>", "<password>", silent = FALSE)
RSeval(c, "1+1")
RSclose(c)

WPS Web Admin Console

Startup the WPS server

  • Start the WPS Admin Console from within your browser
  • Go to "Algorithm Repositories", scroll down for name "LocalRAlgorithmRepository" and class org.n52.wps.server.r.LocalRAlgorithmRepository. If its missing, add it with "add repository", and click "Save and Activate Configuration".
  • Within the repository entry, add / change the following properties according to the Rserve configuration. Save them and click "Save and Activate Configuration":
Rserve_Host (default: localhost)
Rserve_Port (default: 6311)
Rserve_User
Rserve_Password

For more details about how to configure WPS configuration, see here.