Archives for category: Packages

What is KVP – encoding? An OGC forum entry gives an answer, and Wikipedia gives some background. But what is it for the Sensor Observation Service? Well, first of all it is a promised, but undocumented feature! Why is it a promise? Because it is mentioned in section 8.1 of the SOS specification:

Clauses 8, 9, and 10 define the XML encodings for SOS operations. Clause 11 defines the KVP form of each of the operations.

But if you look in the contents section, there simply is not clause 11!

Luckily some people noticed. Eventually, the folks from the OOSTethys project created a best practice documentation of a key value pair encoding for the core SOS operations, which is also implemented by the 52° North SOS: http://www.oostethys.org/best-practices/best-practices-get. The website explains well the background (HTTP, GET et cetera) and the specifications they rely on.

Does it work? To simply receive a capabilities document from a sensor observation service that supports GET and key-value pairs (like the 52° North SOS), just do the following in R:

# using download to file
download.file(
url = "http://giv-sos.uni-muenster.de:8080/52nSOSv3/sos?request=GetCapabilities&version=1.0.0&service=SOS",
destfile = "caps.xml")

# using RCurl
library(RCurl)
caps <- getURL("http://giv-sos.uni-muenster.de:8080/52nSOSv3/sos?request=GetCapabilities&amp;version=1.0.0&amp;service=SOS")
print(caps)

Most of my work goes into parsing and encoding XML files. Luckily, there is a good package available for that in R that I can use. And have to, really, as it is the only one! It is duly titled XML and available on CRAN: http://cran.at.r-project.org/web/packages/XML/index.html. Luckily, the package is available under a BSD license, so no trouble regarding that. There are a bunch of helpful documents with extensive examples available on the project website at http://www.omegahat.org/RSXML/.

Decoding

Nevertheless, let me show you a little code snippet on how I use it, and that is the parsing of an Exception Report as defined in OWS common (OGC Web Services Common). These are my first steps, so I don’t claim this is done cleverly.

Read the rest of this entry »

The topic of today’s post looks ahead in the project a little bit. Within the 52° North Geostatistics Community we currently design a model for spatio-temporal data in R. In other words, how one can save and easily access and query information from a common data structure for data with both a spatial and a temporal component.

This naturally relates to the sos4R project, as it would be great to return exactly these classes as the result of a query to a sensor observation service. On the one side, I do not have to implement these classes alone, on the other side I can count on the R community to develop transformation functions from such a common data model into data structures that can be the basis for a manifold of analyses. I see these output formats as an important part for the acceptance of sos4R in the community.

Our efforts are at a very early stage, but I hope I will be able to contribute as much as I can. We started with an examination of the available R packages for time series and time formats and we think we can use some of them (even if only as orientation). Whether we want to be dependent on one of these packages or rather provide conversion functions is still part of the discussion.

You can check out the current status (not much at the moment despite a graphic with the class structure!) of the package sptX from the 52° North SVN here and participate via the geostatistics mailing list. The goal is to provide classes that are compatible with sp (class conversion etc.) and support various time series and spatial data formats, both regular as well as irregular kinds. sos4R will probably one of the first applications of this package.

One motivation for the SOS4R plugin is reproducible research – and what data could be more appropriate than the question of climate change? I am certainly not saying that all problems (“Climategate“) could be helped with making analysis simpler just because data is easily accessible… but hopefully some!

My two use cases (excerpt from application) that I will base one temperature data are:

First, a researcher wants to use temporally ordered univariate data to create a forecast based on an ARIMA model. She uses the package forecast to achieve her goal.

Second, a point pattern analysis shall be performed. The user wants to analyse covariate effects of spatially distributed data. She uses the package spatstat. An analysis from the workshop paper “Analysing spatial point patterns in R” by Adrian Baddeley is carried out.

Natually, I am not a climate researcher, but nevertheless I’d like to see whether I can make my own temperature model of the earth based on publically available data and Open Source software. Read the rest of this entry »