Set-up R Geoprocessing Backend for 52°North WPS

Authors: Matthias Hinz, Benjamin Proß

1. Download and install the 52°North WPS.

WPS4R is included in the WPS since Version 2.0-RC8-SNAPSHOT. Follow the Installation Guide on the Website.

2. Download and Install R

Go to http://www.r-project.org/ and follow the instructions for your operating system.

3. Configure Environment

  • Add the location of the R executable tho the path-variable in your machine
  • Set the following environment variables on your machine.
    • R_HOME - directory of R installation
    • R_LIBS_USER - preferred user library directory

4. Configure R

Start R, install the package Rserve and all libraries that you need for your processes. You can use the the following command and add/remove packages 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>")
}

5. Setup Rserve

Please refer the official http://www.rforge.net/Rserve/ website for detailed up-to-date information about Rserve.

Local

You can start Rserve from within R on your local machine 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.

cd "%R_HOME%\bin\i386"
START "Rserve" "%R_LIBS_USER%\Rserve\Rserve.exe"

If you run Rserve on localhost with default settings, start the WPS server, it will automatically start Rserve. WPS4R is now ready for use.

Remote

The following steps are required, if you run Rserve from remote connection or want to customize settings, otherwise you can skip it.

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

pwdfile c:/pwd.txt

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.

6. Customize WPS4R via the 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

Metadata

  • Topic created by: DanielNuest
  • Topic created on: 2013-03-21
Topic revision: r4 - 28 Jan 2014, EikeJuerrens
Legal Notice | Privacy Statement


This site is powered by FoswikiCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding Wiki? Send feedback