Using WPS4R for EO2HEAVEN Use Case
Old Workflow
A WMS-Wrapper for a WPS that interacts with an SOS and R. The WPS calls an R Skript (more specifically a function in the script). Input parameters are station identifiers and measurement values. Before that an R workspace is loaded with the required function and data.
Files
wmsConfig wmsConfig.xml
The config file for the WMS wrapper. The only thing happening here is the replacement of the timestamp (
$wms:time$
) and then the WMS calls the WPS.
SaxonyAirQualityIDW.java SaxonyAirQualityIDW.java
The WPS algorithm reading SOS data (station identifiers, measurement values) and then calls the R script. The result of the R script is a
GeoTIFF which is saved into the R workspace and then read in Java. This is currently very combersome because no geodata can directly be transferred between Java and R except using files.
- The data transfer problem will not be solved any time soon... but could be wrapped better, maybe. -- DanielNuest - 2013-01-17
R Script and workspace AirQualityMapping.r AirQualityMapping.RData
The complete script needs more data, but the workspace already contains the required variables. The function
function.getPollutantConentrationAsGeoTiff
is called by the WPS and takes the following inputs: a) a vector with station IDs, b) the corresponding measurement values, c) the pollutant, and d) the name of the output
GeoTIFF.
Suggested Application of WPS4R
All SOS interaction is transferred into the R script, so the former input data vector with actual measurements is not needed anymore.
Input:
- vector with station identifiers
- time
- ISO8601 format, e.g.
2007-12-31T00:00:00.000+0100
(important: time zone explicitly needed)
- observed property
- sos URL
- suggested default:
http://141.30.100.135/eo2heavenSOS/
- offering (= pollutant)
Resources:
- .Rdata file with the functions and list.weights.
Output:
Annotated Script and Request Example
Script:
https://svn.52north.org/svn/geoprocessing/main/WPS/trunk/WPS/52n-wps-webapp/src/main/webapp/R/scripts/eo2h_airqualitysaxony.R
Request:
https://svn.52north.org/svn/geoprocessing/main/WPS/trunk/WPS/52n-wps-webapp/src/main/webapp/requests/R_EO2H_AirQualitySaxony.xml
Description:
http://localhost:8080/wps/WebProcessingService?Request=DescribeProcess&service=WPS&identifier=org.n52.wps.server.r.eo2h_airqualitysaxony
Description file:
processDescription.xml
Resources (preloaded by WPS):
http://localhost:8080/wps/R/resources/EO2H/AirQualityMapping.RData
How to run
- Set up R, Rserve and WPS
- Go to WPS admin console, activate the "LocalRAlgorithmRepository"
- Go to built-in WPS test client, Run the execute request "R_EO2H_AirQualitySaxony.xml" (its within the example requests selection)
- Download the file, add file extension ".tiff" to the filname
Tasks
- %ICON{unchecked} SOS Daten-Download einbauen
Current Problems
- Line 68 was commented out because it causes errors, but the script seems to run without fail though:
#FIXME 'eventTime' does not compute, errormessage:
# Error in sosCreateTime(sos = sos, time = in_time, operator = "TM_Equals") :
# object '.l' not found
#eventTime <- sosCreateTime(sos = sos, time = in_time, operator = "TM_Equals")
- The output file does not contain a filending, it has to be renamed to *.tiff or similar
- Does not work with current sos4R development version ( 0.3-x)
- Topic created by: DanielNuest
- Topic created on: 2013-01-17