WPS4R Setup

  1. Download and install the 52n-WPS with WPS4R integration. Follow these instructions: http://52north.org/maven/project-sites/wps/52n-wps-webapp/installation.html
    Currently WPS4R is only available from source via SVN: https://svn.52north.org/svn/geoprocessing/main/WPS/branches/WPS-R-Project)

  2. Download and install R from http://www.r-project.org/.

  3. Set the following environment variables on your machine:
    R_HOME (directory of R installation)
    R_LIBS_USER (preferred user library directory)

  4. Start R, install the required 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"))

  5. Modify the Rprofile.site file in directory %R_HOME%/etc.
    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>”)
    }


  6. Setup Rserve

    Please refer the official website for detailed up-to-date information about Rserve: http://www.rforge.net/Rserve/. You can start Rserve from within R by the following commands:
    > library(Rserve)
    > Rserve()

    Since Rserve was installed from within R, it should be located under %R_LIBS_USER%/Rserve

    Windows:
    According to the website, you have to put the Rserve binaries in the directory were file "R.dll" is located. That's usually something like %R_HOME%\bin\i386".

    There are alternatives to make Rserve work under windows, but full functionality is not guaranteed: Add the locations of Rserve and R.dll to the environment variable "path" or start Rserve with a batch file of the following content. Eventually have to modify the paths.
    CD "%R_HOME%\bin\i386"
    START "Rserve" "%R_LIBS_USER%\Rserve\Rserve.exe"

  7. If you run Rserve on localhost with default settings, start WPS server and Rserve. WPS4R is ready for use then. The following steps are required, if you run Rserve from remote connection or want to customize settings, otherwise you can skip it.

  8. Customize Rserve

    Create a file called “Rserv.cfg” and place it into the directory of the Rserve binaries. Customize the following settings; they suit for running the R backend from remote connection and with user authentication. For details and more parameters refer the Rserve-documentation.

    pwdfile c:/pwd.txt
    remote enable
    auth required
    port 6312
    encoding utf8

    The password file should be an ASCII file with-line-per-line user entries of format. It should be declared by an absolute path because relative paths refer to the R workdirectory. The filename is regardless.

    user password


  9. Customize WPS4R with the Web Admin Console

Image: How to add properties
Figure 1: Repository entry for R backend, displays how to add properties according to the Rserve configuration