sos4R: Accessing Sensor Observation Services from R – Quickstart

Daniel Nüst

Institute for Geoinformatics, University of Münster, Germany.
[email protected]

2019-08-09

Abstract

The sos4R package provides simple yet powerful access to OGC Sensor Observation Service instances. The package supports both encapsulation and abstraction from the service interface for novice users as well as powerful request building for specialists. sos4R is motivated by the idea to close the gap between the Sensor Web and tools for (geo-)statistical analyses. It implements the core profile of the SOS specification and supports temporal, spatial, and thematical filtering of observations.

This document gives a brief overview and demo. Other vignettes dive deeper into the SOS specification and the package’s features are explained extensively: exploration of service metadata, request building with filters, function exchangeability, result data transformation.

The package is published under GPL 2 license within the geostatistics community of 52°North Initiative for Geospatial Open Source Software.

Introduction

The sos4R package provides classes and methods for retrieving data from an Open Geospatial Consortium (OGC) Sensor Observation Service in version 1.0.0 (Na, 2007) and 2.0 (Bröring, 2010). The goal of this package is to provide easy access with a low entry threshold for everyone to information available via SOSs. The complexity of the service interface shall be shielded from the user as much as possible, while still leaving enough possiblities for advanced users. The output is a standard data.frame with attributed columns for the rich metadata provided by the SOS API. This package uses S4 classes and methods style (Chambers, 1998).

The package was born out of perceiving a missing link between the Sensor Web community (known as Sensor Web Enablement (SWE) Initiative in the OGC realm) and the community of (geo-)statisticians (Nüst, 2011). While the relatively young SWE standards get adopted more by data owners (like governmental organizations), we see a high but unused potential for more open data and spatio-temporal analyses based on it. sos4R can help enabling this.

The project is part of the geostatistics community of the 52°North Initiative for Geospatial Open Source Software. sos4R is available on CRAN.

On the package home page, https://52north.github.io/sos4R, you can stay updated with the developments and find example code and services.

This software is released under a GPL 2 license and contributions are very welcome—please see the file DEV-README.md in the package code repository.

library("sos4R")

Getting started

Cheat sheet

The package comes with a one page quick reference card, also known as a “cheat sheet”, which shows everything that you need to know in an extremely concise manner. You can open the document by loading the package and calling

The most useful functions are highlighted in bold font.

Demos and services

The demos are a good way to get started with the package. Please be aware that you need an internet connection for these demos, the used SOSs might be temporarily unavailable or not available anymore.

There also is an incomplete list of services that have been tested or are currently evaluated on the project homepage. If you find or can provide new SOS with data useful to others, please do not hesitate to open an issue so that it can be included.

Additionally, a set of SOS URLs are available via the function SosExampleServices(). Please note that the author of this document does not control these services and does not guarantee for any factors like correctness of data or availability.

Creating a SOS connection

The method SOS() is a construction method for classes encapsulating a connection to a SOS. It prints out a short statement when the connection was successfully established (i.e. the capabilities document was received) and returns an object of class SOS.

To create a SOS connection you only need the URL of the service (i.e. the URL endpoint which can be used for HTTP requests). The service connection created above is used for all examples throughout this document.

All parameters except the service endpoint are optional and use default settings:

There are accessor methods for the slots of the class. The encoders, parsers and converters are described extensively in the vignette “Extending”.

You can also access the used encoding, decoding, and conversion functions (extensive output not included here).

Print and summary methods are available for important classes, like SOS.

Get Data

The GetObservation operation is the main data download request of the SOS, and the package’s functional equivalent is getObservation(..). You can build a request using the information from the offerings, as they are extracted from the capabilities document when a new connection is created.

off.1 <- sosOfferings(mySOS)[[1]]
summary(off.1)
#> Object of class SosObservationOffering
#> [[id:]]      [1] "ws2500"
#> [[name:]]    [1] NA
#> [[time:]]    [1] "2015-05-18 08:35:00 --> 2018-01-06 05:45:00"
#> [[bbox:]]    [1] "urn:ogc:def:crs:EPSG::4326, 51.934814453125 7.652428150177, 51.934814453125 7.652428150177"
#> [[fois:]]    [1] 1
#> [[procs:]]   [1] 1
#> [[obsProps:]]    [1] 10
sosProcedures(off.1)
#> [1] "ws2500"
sosObservedProperties(off.1)
#> [[1]]
#> [1] "AirTemperature"
#> 
#> [[2]]
#> [1] "AthmosphericPressure"
#> 
#> [[3]]
#> [1] "Dewpoint"
#> 
#> [[4]]
#> [1] "Humidity"
#> 
#> [[5]]
#> [1] "Luminance"
#> 
#> [[6]]
#> [1] "RainfallAccumulated"
#> 
#> [[7]]
#> [1] "Sunshine"
#> 
#> [[8]]
#> [1] "WindDirection"
#> 
#> [[9]]
#> [1] "WindSpeed"
#> 
#> [[10]]
#> [1] "Windchill"
sosFeaturesOfInterest(off.1)
#> [[1]]
#> [1] "ELV-WS2500"

Not all combinations of procedure, observed property, feature of interest, and event time will deliver a result, but the following one should.

obs.1 <- getObservation(sos = mySOS,
  offering = off.1,
  procedure = sosProcedures(off.1)[[1]],
    observedProperty = sosObservedProperties(off.1)[1],
    eventTime = sosCreateTime(sos = mySOS, time = "2017-12-19::2017-12-20"))
#> [sos4R] Finished getObservation to http://sensorweb.demo.52north.org/sensorwebtestbed/service/kvp 
#>  --> received 1 observation(s) having 72 result values [ 72 ].

You can then access the result data with the helper function sosResult(..).

#sosResult(data)
summary(sosResult(obs.1))
#>  phenomenonTime                AirTemperature
#>  Min.   :2017-12-19 00:30:00   Min.   :22.8  
#>  1st Qu.:2017-12-19 06:26:15   1st Qu.:22.8  
#>  Median :2017-12-19 12:15:00   Median :22.8  
#>  Mean   :2017-12-19 12:15:12   Mean   :22.8  
#>  3rd Qu.:2017-12-19 18:07:30   3rd Qu.:22.8  
#>  Max.   :2017-12-20 00:00:00   Max.   :22.8

Inspect Requests and Verbose Printing

The package offers two levels of inspection of the ongoing operations indicated by two boolean parameters, inspect and verbose. These are available in all service operation calls.

The option verboseOutput when using the method SOS() turns on the verbose setting for all subsequent requests made to the created connection unless deactivated in an operation call.

obs.1 <- getObservation(sos = mySOS, offering = off.1,
    procedure = sosProcedures(off.1)[[1]],
    observedProperty = sosObservedProperties(off.1)[1],
    eventTime = sosCreateTime(sos = mySOS, time = "2017-12-19::2017-12-20"),
    inspect = TRUE)
#> [.sosRequest_1.0.0] GET!
#> [.sosRequest_1.0.0] REQUEST:
#>   http://sensorweb.demo.52north.org/sensorwebtestbed/service/kvp?service=SOS&version=1.0.0&request=GetObservation&offering=ws2500&observedProperty=AirTemperature&responseFormat=text%2Fxml%3Bsubtype%3D%22om%2F1.0.0%22&eventTime=2017-12-19T00%3A00%3A00%2F2017-12-20T00%3A00%3A00&procedure=ws2500 
#> [.getObservation_1.0.0] RESPONSE DOC:
#> {xml_document}
#> <ObservationCollection id="oc_1565356433492" schemaLocation="http://www.opengis.net/om/1.0 http://schemas.opengis.net/om/1.0.0/om.xsd http://www.opengis.net/sampling/1.0 http://schemas.opengis.net/sampling/1.0.0/sampling.xsd http://www.opengis.net/sos/1.0 http://schemas.opengis.net/sos/1.0.0/sosAll.xsd http://www.opengis.net/gml http://schemas.opengis.net/gml/3.1.1/base/gml.xsd http://www.opengis.net/swe/1.0.1 http://schemas.opengis.net/sweCommon/1.0.1/swe.xsd" xmlns:om="http://www.opengis.net/om/1.0" xmlns:gml="http://www.opengis.net/gml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sa="http://www.opengis.net/sampling/1.0" xmlns:swe="http://www.opengis.net/swe/1.0.1">
#> [1] <gml:boundedBy>\n  <gml:Envelope srsName="urn:ogc:def:crs:EPSG::4326 ...
#> [2] <om:member>\n  <om:Observation gml:id="o_1565356433492">\n    <om:sa ...
#> [sos4R] Finished getObservation to http://sensorweb.demo.52north.org/sensorwebtestbed/service/kvp 
#>  --> received 1 observation(s) having 72 result values [ 72 ].
getObservation(sos = mySOS, offering = off.1,
    procedure = sosProcedures(off.1)[[1]],
    observedProperty = sosObservedProperties(off.1)[2],
    eventTime = sosCreateTime(sos = mySOS, time = "2018-01-01::2018-01-03"),
    verbose = TRUE)
#> [getObservation] Requesting offering ws2500 by SosObservationOffering.
#> [.getObservation_1.0.0] to  http://sensorweb.demo.52north.org/sensorwebtestbed/service/kvp  with offering  ws2500 
#> [.createGetObservation_1.0.0] Done:
#>  Object of class SosGetObservation:  service:  SOS , version:  1.0.0 , offering:  ws2500 
#> observered property:  AthmosphericPressure 
#> responseFormat(s):  text/xml;subtype="om/1.0.0" , responseMode(s):  NA 
#> procedure(s) ws2500 
#>  feature(s) of interest  
#>  event time:  new("SosEventTime", temporalOps = new("TM_During", time = new("GmlTimePeriod", begin = NULL, beginPosition = new("GmlTimePosition", time = 1514761200, frame = NA, calendarEraName = NA, indeterminatePosition = NA), end = NULL, endPosition = new("GmlTimePosition", time = 1514934000, frame = NA, calendarEraName = NA, indeterminatePosition = NA), duration = NA, timeInterval = NULL, frame = NA, relatedTimes = list(NA), id = NA), propertyName = "om:samplingTime")) 
#>  result:  NULL 
#> srsName:  NA 
#> resultModel(s):  NA 
#> temporal value reference:  NA 
#>  
#> [.getObservation_1.0.0] REQUEST:
#> 
#>  Object of class SosGetObservation:  service:  SOS , version:  1.0.0 , offering:  ws2500 
#> observered property:  AthmosphericPressure 
#> responseFormat(s):  text/xml;subtype="om/1.0.0" , responseMode(s):  NA 
#> procedure(s) ws2500 
#>  feature(s) of interest  
#>  event time:  new("SosEventTime", temporalOps = new("TM_During", time = new("GmlTimePeriod", begin = NULL, beginPosition = new("GmlTimePosition", time = 1514761200, frame = NA, calendarEraName = NA, indeterminatePosition = NA), end = NULL, endPosition = new("GmlTimePosition", time = 1514934000, frame = NA, calendarEraName = NA, indeterminatePosition = NA), duration = NA, timeInterval = NULL, frame = NA, relatedTimes = list(NA), id = NA), propertyName = "om:samplingTime")) 
#>  result:  NULL 
#> srsName:  NA 
#> resultModel(s):  NA 
#> temporal value reference:  NA 
#>  
#> [.sosRequest_1.0.0] Encoding Function (beginning of function body):  { standardGeneric("encodeRequestKVP")  ... [ 0  more chrs].
#> [.sosEncodeRequestKVPGetObservation_1.0.0] encoding Object of class SosGetObservation:  service:  SOS , version:  1.0.0 , offering:  ws2500 
#> observered property:  AthmosphericPressure 
#> responseFormat(s):  text/xml;subtype="om/1.0.0" , responseMode(s):  NA 
#> procedure(s) ws2500 
#>  feature(s) of interest  
#>  event time:  new("SosEventTime", temporalOps = new("TM_During", time = new("GmlTimePeriod", begin = NULL, beginPosition = new("GmlTimePosition", time = 1514761200, frame = NA, calendarEraName = NA, indeterminatePosition = NA), end = NULL, endPosition = new("GmlTimePosition", time = 1514934000, frame = NA, calendarEraName = NA, indeterminatePosition = NA), duration = NA, timeInterval = NULL, frame = NA, relatedTimes = list(NA), id = NA), propertyName = "om:samplingTime")) 
#>  result:  NULL 
#> srsName:  NA 
#> resultModel(s):  NA 
#> temporal value reference:  NA 
#>  
#> [.sosEncodeRequestKVPGetObservation_1.0.0] mandatory elements:  service=SOS&version=1.0.0&request=GetObservation&offering=ws2500&observedProperty=AthmosphericPressure 
#> [.sosEncodeRequestKVPGetObservation_1.0.0] Adding response format  text/xml;subtype="om/1.0.0" 
#> [.sosEncodeRequestKVPGetObservation_1.0.0] Adding event time new("SosEventTime", temporalOps = new("TM_During", time = new("GmlTimePeriod", begin = NULL, beginPosition = new("GmlTimePosition", time = 1514761200, frame = NA, calendarEraName = NA, indeterminatePosition = NA), end = NULL, endPosition = new("GmlTimePosition", time = 1514934000, frame = NA, calendarEraName = NA, indeterminatePosition = NA), duration = NA, timeInterval = NULL, frame = NA, relatedTimes = list(NA), id = NA), propertyName = "om:samplingTime")) 
#> ENCODE KVP  SosEventTime 
#> [encodeKVP] temporalOps:  Object of class TM_During; propertyName: om:samplingTime time: GmlTimePeriod: [ GmlTimePosition [ time: 2018-01-01 ]
#>  --> GmlTimePosition [ time: 2018-01-03 ] ] 
#> [encodeKVP] Encoding period with beginPosition and endPosition.
#> [encodeKVP] POSIXt with value 2018-01-01 
#> Formatted  1514761200  to  2018-01-01T00:00:00 
#> [encodeKVP] POSIXt with value 2018-01-03 
#> Formatted  1514934000  to  2018-01-03T00:00:00 
#> [.sosEncodeRequestKVPGetObservation_1.0.0] Adding procedures  ws2500 
#> [.sosEncodeRequestKVPGetObservation_1.0.0] optional elements:  &responseFormat=text%2Fxml%3Bsubtype%3D%22om%2F1.0.0%22&eventTime=2018-01-01T00%3A00%3A00%2F2018-01-03T00%3A00%3A00&procedure=ws2500 
#> [.sosEncodeRequestKVPGetObservation_1.0.0] Finished KVP string creation:
#>  service=SOS&version=1.0.0&request=GetObservation&offering=ws2500&observedProperty=AthmosphericPressure&responseFormat=text%2Fxml%3Bsubtype%3D%22om%2F1.0.0%22&eventTime=2018-01-01T00%3A00%3A00%2F2018-01-03T00%3A00%3A00&procedure=ws2500 
#> [.sosRequest_1.0.0] Using DCP from operation description.
#> [.sosFilterDCPs] Applying pattern * to http://sensorweb.demo.52north.org/sensorwebtestbed/service/kvp? 
#> [.sosFilterDCPs] Filtered from
#>   http://sensorweb.demo.52north.org/sensorwebtestbed/service/kvp? 
#>  to
#>   http://sensorweb.demo.52north.org/sensorwebtestbed/service/kvp? 
#> Given url already contains a '?', appending arguments!
#> [.sosRequest_1.0.0] Do request...
#> [.processResponse] Response status:  200  | type:  application/xml 
#> [.sosRequest_1.0.0] ... done.
#> [.sosRequest_1.0.0] RESPONSE:
#> {xml_document}
#> <ObservationCollection id="oc_1565356433585" schemaLocation="http://www.opengis.net/om/1.0 http://schemas.opengis.net/om/1.0.0/om.xsd http://www.opengis.net/sampling/1.0 http://schemas.opengis.net/sampling/1.0.0/sampling.xsd http://www.opengis.net/sos/1.0 http://schemas.opengis.net/sos/1.0.0/sosAll.xsd http://www.opengis.net/gml http://schemas.opengis.net/gml/3.1.1/base/gml.xsd http://www.opengis.net/swe/1.0.1 http://schemas.opengis.net/sweCommon/1.0.1/swe.xsd" xmlns:om="http://www.opengis.net/om/1.0" xmlns:gml="http://www.opengis.net/gml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sa="http://www.opengis.net/sampling/1.0" xmlns:swe="http://www.opengis.net/swe/1.0.1">
#> [1] <gml:boundedBy>\n  <gml:Envelope srsName="urn:ogc:def:crs:EPSG::4326 ...
#> [2] <om:member>\n  <om:Observation gml:id="o_1565356433585">\n    <om:sa ...
#> [sos4R] Received response (object size: 784 bytes), parsing ...
#> [.getObservation_1.0.0] Got XML document as response.
#> [.getObservation_1.0.0] Parsing with function function (obj, sos, verbose = FALSE) 
#> {
#>     .om <- NULL
#>     .name <- xml2::xml_name(x = obj, ns = SosAllNamespaces())
#>     .parsingFunction <- sosParsers(sos)[[.name]]
#>     if (!is.null(.parsingFunction)) {
#>         if (verbose) 
#>             cat("[parseOM] Matched name for parser is", .name, 
#>                 "\n")
#>         .om <- .parsingFunction(obj = obj, sos = sos, verbose = verbose)
#>         if (verbose) 
#>             cat("[parseOM] Done parsing\n")
#>     }
#>     else {
#>         warning(paste("[parseOM] No parsing function for given element", 
#>             .name))
#>     }
#>     return(.om)
#> }
#> <bytecode: 0x563f8fb099f8>
#> <environment: namespace:sos4R>
#> [parseOM] Matched name for parser is om:ObservationCollection 
#> [parseObservationCollection] with  1 element(s).
#> [parseObservationCollection] Parsed envelope: urn:ogc:def:crs:EPSG::4326, 51.934814453125 7.652428150177, 51.934814453125 7.652428150177 
#> [parseOM] Matched name for parser is om:member 
#> [parseObservationProperty] Parsing child of member: om:Observation 
#> [parseOM] Matched name for parser is om:Observation 
#> [parseObservation] o_1565356433585 
#> [parsePhenomenonProperty] with reference AthmosphericPressure 
#> [parseTime] Entering
#> [parseTime] Found time period
#> [parseTime] Done: GmlTimePeriod: [ GmlTimePosition [ time: 2018-01-01 00:30:00 ]
#>  --> GmlTimePosition [ time: 2018-01-03 ] ] 
#> [parseFOI] starting...
#> [parseFOI] inline FOI: sa:SamplingPoint 
#> [parseResult] Starting ...
#> [parseResult] 1  non-text nodes, names: DataArray 
#> [parseResult] Parsing result with swe:DataArray.
#> [parseDataArray] Parsing DataArray with 144 elements.
#> [parseElementType] Got child DataRecord and id NA for object elementType 
#> [parseElementType] Got data record with 2 fields. 
#> [parseField] Parsing field description of  phenomenonTime 
#> [parseField] Parsed field phenomenonTime, http://www.opengis.net/def/property/OGC/0/PhenomenonTime 
#> [parseField] Parsing field description of  AthmosphericPressure 
#> [parseField] Parsed field AthmosphericPressure, AthmosphericPressure, hPa 
#> [parseElementType] Names of parsed fields: 
#> [parseDataArray] Parsed field descriptions: c(name = "phenomenonTime", definition = "http://www.opengis.net/def/property/OGC/0/PhenomenonTime"), c(name = "AthmosphericPressure", definition = "AthmosphericPressure", uom = "hPa") 
#> [parseDataArray] Parsed encoding description: Object of class SweTextBlock ', @@ .'; id: NA 
#> [parseValues] Parsing swe:values using Object of class SweTextBlock ', @@ .'; id: NA and 2 fields: phenomenonTime, AthmosphericPressure 
#> [parseValues] Parsing values from lines:  c("2018-01-01T00:30:00.000Z", "990.0"), c("2018-01-01T00:45:00.000Z", "990.0"), c("2018-01-01T01:00:00.000Z", "990.0"), c("2018-01-01T01:30:00.000Z", "990.0"), c("2018-01-01T01:45:00.000Z", "990.0"), c("2018-01-01T02:00:00.000Z", "990.0"), c("2018-01-01T02:30:00.000Z", "990.0"), c("2018-01-01T02:45:00.000Z", "990.0"), c("2018-01-01T03:00:00.000Z", "990.0"), c("2018-01-01T03:30:00.000Z", "990.0"), c("2018-01-01T03:45:00.000Z", "990.0"), c("2018-01-01T04:00:00.000Z", "990.0"), c("2018-01-01T04:30:00.000Z", "991.0"), c("2018-01-01T04:45:00.000Z", "991.0"), c("2018-01-01T05:00:00.000Z", "991.0"), c("2018-01-01T05:30:00.000Z", "992.0"), c("2018-01-01T05:45:00.000Z", "992.0"), c("2018-01-01T06:15:00.000Z", "992.0"), c("2018-01-01T06:30:00.000Z", "993.0"), c("2018-01-01T06:45:00.000Z", "993.0"), c("2018-01-01T07:00:00.000Z", "993.0"), c("2018-01-01T07:30:00.000Z", "994.0"), c("2018-01-01T07:45:00.000Z", "994.0"), c("2018-01-01T08:00:00.000Z", "994.0"), c("2018-01-01T08:30:00.000Z", "994.0"), c("2018-01-01T08:45:00.000Z", "994.0"), c("2018-01-01T09:00:00.000Z", "994.0"), c("2018-01-01T09:30:00.000Z", "995.0"), c("2018-01-01T09:45:00.000Z", "995.0"), c("2018-01-01T10:00:00.000Z", "995.0"), c("2018-01-01T10:30:00.000Z", "994.0"), c("2018-01-01T10:45:00.000Z", "994.0"), c("2018-01-01T11:00:00.000Z", "994.0"), c("2018-01-01T11:30:00.000Z", "994.0"), c("2018-01-01T11:45:00.000Z", "994.0"), c("2018-01-01T12:00:00.000Z", "993.0"), c("2018-01-01T12:30:00.000Z", "993.0"), c("2018-01-01T12:45:00.000Z", "993.0"), c("2018-01-01T13:00:00.000Z", "993.0"), c("2018-01-01T13:30:00.000Z", "992.0"), c("2018-01-01T13:45:00.000Z", "992.0"), c("2018-01-01T14:00:00.000Z", "992.0"), c("2018-01-01T14:30:00.000Z", "991.0"), c("2018-01-01T14:45:00.000Z", "991.0"), c("2018-01-01T15:00:00.000Z", "991.0"), c("2018-01-01T15:30:00.000Z", "991.0"), c("2018-01-01T15:45:00.000Z", "990.0"), c("2018-01-01T16:00:00.000Z", "990.0"), c("2018-01-01T16:30:00.000Z", "990.0"), c("2018-01-01T16:45:00.000Z", "990.0"), c("2018-01-01T17:00:00.000Z", "990.0"), c("2018-01-01T17:30:00.000Z", "990.0"), c("2018-01-01T17:45:00.000Z", "990.0"), c("2018-01-01T18:00:00.000Z", "990.0"), c("2018-01-01T18:30:00.000Z", "989.0"), c("2018-01-01T18:45:00.000Z", "989.0"), c("2018-01-01T19:00:00.000Z", "989.0"), c("2018-01-01T19:30:00.000Z", "989.0"), c("2018-01-01T19:45:00.000Z", "989.0"), c("2018-01-01T20:00:00.000Z", "989.0"), c("2018-01-01T20:30:00.000Z", "989.0"), c("2018-01-01T20:45:00.000Z", "990.0"), c("2018-01-01T21:00:00.000Z", "990.0"), c("2018-01-01T21:30:00.000Z", "990.0"), c("2018-01-01T21:45:00.000Z", "990.0"), c("2018-01-01T22:00:00.000Z", "991.0"), c("2018-01-01T22:30:00.000Z", "991.0"), c("2018-01-01T22:45:00.000Z", "991.0"), c("2018-01-01T23:00:00.000Z", "992.0"), c("2018-01-01T23:30:00.000Z", "993.0"), c("2018-01-01T23:45:00.000Z", "993.0"), c("2018-01-02T00:00:00.000Z", "993.0"), c("2018-01-02T00:30:00.000Z", "993.0"), c("2018-01-02T00:45:00.000Z", "994.0"), c("2018-01-02T01:00:00.000Z", "994.0"), c("2018-01-02T01:30:00.000Z", "995.0"), c("2018-01-02T01:45:00.000Z", "995.0"), c("2018-01-02T02:00:00.000Z", "995.0"), c("2018-01-02T02:30:00.000Z", "996.0"), c("2018-01-02T02:45:00.000Z", "996.0"), c("2018-01-02T03:00:00.000Z", "996.0"), c("2018-01-02T03:30:00.000Z", "996.0"), c("2018-01-02T03:45:00.000Z", "997.0"), c("2018-01-02T04:00:00.000Z", "997.0"), c("2018-01-02T04:30:00.000Z", "997.0"), c("2018-01-02T04:45:00.000Z", "997.0"), c("2018-01-02T05:00:00.000Z", "998.0"), c("2018-01-02T05:30:00.000Z", "998.0"), c("2018-01-02T05:45:00.000Z", "998.0"), c("2018-01-02T06:15:00.000Z", "999.0"), c("2018-01-02T06:30:00.000Z", "999.0"), c("2018-01-02T06:45:00.000Z", "999.0"), c("2018-01-02T07:00:00.000Z", "1000.0"), c("2018-01-02T07:30:00.000Z", "1000.0"), c("2018-01-02T07:45:00.000Z", "1000.0"), c("2018-01-02T08:00:00.000Z", "1000.0"), c("2018-01-02T08:30:00.000Z", "1001.0"), c("2018-01-02T08:45:00.000Z", "1001.0"), c("2018-01-02T09:00:00.000Z", "1001.0"), c("2018-01-02T09:30:00.000Z", "1002.0"), c("2018-01-02T09:45:00.000Z", "1002.0"), c("2018-01-02T10:00:00.000Z", "1002.0"), c("2018-01-02T10:30:00.000Z", "1003.0"), c("2018-01-02T10:45:00.000Z", "1003.0"), c("2018-01-02T11:00:00.000Z", "1003.0"), c("2018-01-02T11:30:00.000Z", "1003.0"), c("2018-01-02T11:45:00.000Z", "1003.0"), c("2018-01-02T12:00:00.000Z", "1003.0"), c("2018-01-02T12:30:00.000Z", "1003.0"), c("2018-01-02T12:45:00.000Z", "1003.0"), c("2018-01-02T13:00:00.000Z", "1003.0"), c("2018-01-02T13:30:00.000Z", "1003.0"), c("2018-01-02T13:45:00.000Z", "1003.0"), c("2018-01-02T14:00:00.000Z", "1003.0"), c("2018-01-02T14:30:00.000Z", "1003.0"), c("2018-01-02T14:45:00.000Z", "1003.0"), c("2018-01-02T15:00:00.000Z", "1002.0"), c("2018-01-02T15:30:00.000Z", "1002.0"), c("2018-01-02T15:45:00.000Z", "1002.0"), c("2018-01-02T16:00:00.000Z", "1002.0"), c("2018-01-02T16:30:00.000Z", "1002.0"), c("2018-01-02T16:45:00.000Z", "1002.0"), c("2018-01-02T17:00:00.000Z", "1001.0"), c("2018-01-02T17:30:00.000Z", "1001.0"), c("2018-01-02T17:45:00.000Z", "1001.0"), c("2018-01-02T18:00:00.000Z", "1000.0"), c("2018-01-02T18:30:00.000Z", "1000.0"), c("2018-01-02T18:45:00.000Z", "1000.0"), c("2018-01-02T19:00:00.000Z", "999.0"), c("2018-01-02T19:30:00.000Z", "999.0"), c("2018-01-02T19:45:00.000Z", "998.0"), c("2018-01-02T20:00:00.000Z", "998.0"), c("2018-01-02T20:30:00.000Z", "997.0"), c("2018-01-02T20:45:00.000Z", "997.0"), c("2018-01-02T21:00:00.000Z", "996.0"), c("2018-01-02T21:30:00.000Z", "995.0"), c("2018-01-02T21:45:00.000Z", "995.0"), c("2018-01-02T22:00:00.000Z", "994.0"), c("2018-01-02T22:30:00.000Z", "993.0"), c("2018-01-02T22:45:00.000Z", "993.0"), c("2018-01-02T23:00:00.000Z", "992.0"), c("2018-01-02T23:30:00.000Z", "991.0"), c("2018-01-02T23:45:00.000Z", "991.0"), c("2018-01-03T00:00:00.000Z", "990.0") 
#> [parseValues] Processing field index 1 of 2 
#> [parseValues] Current values:  2018-01-01T00:30:00.000Z, 2018-01-01T00:45:00.000Z, 2018-01-01T01:00:00.000Z, 2018-01-01T01:30:00.000Z, 2018-01-01T01:45:00.000Z, 2018-01-01T02:00:00.000Z, 2018-01-01T02:30:00.000Z, 2018-01-01T02:45:00.000Z, 2018-01-01T03:00:00.000Z, 2018-01-01T03:30:00.000Z, 2018-01-01T03:45:00.000Z, 2018-01-01T04:00:00.000Z, 2018-01-01T04:30:00.000Z, 2018-01-01T04:45:00.000Z, 2018-01-01T05:00:00.000Z, 2018-01-01T05:30:00.000Z, 2018-01-01T05:45:00.000Z, 2018-01-01T06:15:00.000Z, 2018-01-01T06:30:00.000Z, 2018-01-01T06:45:00.000Z, 2018-01-01T07:00:00.000Z, 2018-01-01T07:30:00.000Z, 2018-01-01T07:45:00.000Z, 2018-01-01T08:00:00.000Z, 2018-01-01T08:30:00.000Z, 2018-01-01T08:45:00.000Z, 2018-01-01T09:00:00.000Z, 2018-01-01T09:30:00.000Z, 2018-01-01T09:45:00.000Z, 2018-01-01T10:00:00.000Z, 2018-01-01T10:30:00.000Z, 2018-01-01T10:45:00.000Z, 2018-01-01T11:00:00.000Z, 2018-01-01T11:30:00.000Z, 2018-01-01T11:45:00.000Z, 2018-01-01T12:00:00.000Z, 2018-01-01T12:30:00.000Z, 2018-01-01T12:45:00.000Z, 2018-01-01T13:00:00.000Z, 2018-01-01T13:30:00.000Z, 2018-01-01T13:45:00.000Z, 2018-01-01T14:00:00.000Z, 2018-01-01T14:30:00.000Z, 2018-01-01T14:45:00.000Z, 2018-01-01T15:00:00.000Z, 2018-01-01T15:30:00.000Z, 2018-01-01T15:45:00.000Z, 2018-01-01T16:00:00.000Z, 2018-01-01T16:30:00.000Z, 2018-01-01T16:45:00.000Z, 2018-01-01T17:00:00.000Z, 2018-01-01T17:30:00.000Z, 2018-01-01T17:45:00.000Z, 2018-01-01T18:00:00.000Z, 2018-01-01T18:30:00.000Z, 2018-01-01T18:45:00.000Z, 2018-01-01T19:00:00.000Z, 2018-01-01T19:30:00.000Z, 2018-01-01T19:45:00.000Z, 2018-01-01T20:00:00.000Z, 2018-01-01T20:30:00.000Z, 2018-01-01T20:45:00.000Z, 2018-01-01T21:00:00.000Z, 2018-01-01T21:30:00.000Z, 2018-01-01T21:45:00.000Z, 2018-01-01T22:00:00.000Z, 2018-01-01T22:30:00.000Z, 2018-01-01T22:45:00.000Z, 2018-01-01T23:00:00.000Z, 2018-01-01T23:30:00.000Z, 2018-01-01T23:45:00.000Z, 2018-01-02T00:00:00.000Z, 2018-01-02T00:30:00.000Z, 2018-01-02T00:45:00.000Z, 2018-01-02T01:00:00.000Z, 2018-01-02T01:30:00.000Z, 2018-01-02T01:45:00.000Z, 2018-01-02T02:00:00.000Z, 2018-01-02T02:30:00.000Z, 2018-01-02T02:45:00.000Z, 2018-01-02T03:00:00.000Z, 2018-01-02T03:30:00.000Z, 2018-01-02T03:45:00.000Z, 2018-01-02T04:00:00.000Z, 2018-01-02T04:30:00.000Z, 2018-01-02T04:45:00.000Z, 2018-01-02T05:00:00.000Z, 2018-01-02T05:30:00.000Z, 2018-01-02T05:45:00.000Z, 2018-01-02T06:15:00.000Z, 2018-01-02T06:30:00.000Z, 2018-01-02T06:45:00.000Z, 2018-01-02T07:00:00.000Z, 2018-01-02T07:30:00.000Z, 2018-01-02T07:45:00.000Z, 2018-01-02T08:00:00.000Z, 2018-01-02T08:30:00.000Z, 2018-01-02T08:45:00.000Z, 2018-01-02T09:00:00.000Z, 2018-01-02T09:30:00.000Z, 2018-01-02T09:45:00.000Z, 2018-01-02T10:00:00.000Z, 2018-01-02T10:30:00.000Z, 2018-01-02T10:45:00.000Z, 2018-01-02T11:00:00.000Z, 2018-01-02T11:30:00.000Z, 2018-01-02T11:45:00.000Z, 2018-01-02T12:00:00.000Z, 2018-01-02T12:30:00.000Z, 2018-01-02T12:45:00.000Z, 2018-01-02T13:00:00.000Z, 2018-01-02T13:30:00.000Z, 2018-01-02T13:45:00.000Z, 2018-01-02T14:00:00.000Z, 2018-01-02T14:30:00.000Z, 2018-01-02T14:45:00.000Z, 2018-01-02T15:00:00.000Z, 2018-01-02T15:30:00.000Z, 2018-01-02T15:45:00.000Z, 2018-01-02T16:00:00.000Z, 2018-01-02T16:30:00.000Z, 2018-01-02T16:45:00.000Z, 2018-01-02T17:00:00.000Z, 2018-01-02T17:30:00.000Z, 2018-01-02T17:45:00.000Z, 2018-01-02T18:00:00.000Z, 2018-01-02T18:30:00.000Z, 2018-01-02T18:45:00.000Z, 2018-01-02T19:00:00.000Z, 2018-01-02T19:30:00.000Z, 2018-01-02T19:45:00.000Z, 2018-01-02T20:00:00.000Z, 2018-01-02T20:30:00.000Z, 2018-01-02T20:45:00.000Z, 2018-01-02T21:00:00.000Z, 2018-01-02T21:30:00.000Z, 2018-01-02T21:45:00.000Z, 2018-01-02T22:00:00.000Z, 2018-01-02T22:30:00.000Z, 2018-01-02T22:45:00.000Z, 2018-01-02T23:00:00.000Z, 2018-01-02T23:30:00.000Z, 2018-01-02T23:45:00.000Z, 2018-01-03T00:00:00.000Z 
#> [parseValues] Parsing field phenomenonTime http://www.opengis.net/def/property/OGC/0/PhenomenonTime 
#> [parseValues] Using converter:
#> function (x, sos) 
#> {
#>     .t <- as.POSIXct(x = strptime(x = x, format = sosTimeFormat(sos = sos)))
#>     return(.t)
#> }
#> <bytecode: 0x563f8fb69450>
#> <environment: namespace:sos4R>
#> [parseValues] Using converter function:
#> function (x, sos) 
#> {
#>     .t <- as.POSIXct(x = strptime(x = x, format = sosTimeFormat(sos = sos)))
#>     return(.t)
#> }
#> <bytecode: 0x563f8fb69450>
#> <environment: namespace:sos4R>
#> [parseValues] Binding additional data.frame for phenomenonTime -- value range 2018-01-01 00:30:00, 2018-01-03 00:00:00 
#> [parseValues] Added column name: phenomenonTime 
#> [parseValues] The new bound data frame (one variable the a temp id):
#> 'data.frame':    144 obs. of  2 variables:
#>  $ tempID        : int  1 2 3 4 5 6 7 8 9 10 ...
#>  $ phenomenonTime: POSIXct, format: "2018-01-01 00:30:00" "2018-01-01 00:45:00" ...
#> [parseValues] Added attributes to new data: phenomenonTime, http://www.opengis.net/def/property/OGC/0/PhenomenonTime [ names:  name, definition ] 
#> [parseValues] Old attributes list is c("POSIXct", "POSIXt"),  
#> [parseValues] New attributes list is c("POSIXct", "POSIXt"), , phenomenonTime, http://www.opengis.net/def/property/OGC/0/PhenomenonTime 
#> [parseValues] Processing field index 2 of 2 
#> [parseValues] Current values:  990.0, 990.0, 990.0, 990.0, 990.0, 990.0, 990.0, 990.0, 990.0, 990.0, 990.0, 990.0, 991.0, 991.0, 991.0, 992.0, 992.0, 992.0, 993.0, 993.0, 993.0, 994.0, 994.0, 994.0, 994.0, 994.0, 994.0, 995.0, 995.0, 995.0, 994.0, 994.0, 994.0, 994.0, 994.0, 993.0, 993.0, 993.0, 993.0, 992.0, 992.0, 992.0, 991.0, 991.0, 991.0, 991.0, 990.0, 990.0, 990.0, 990.0, 990.0, 990.0, 990.0, 990.0, 989.0, 989.0, 989.0, 989.0, 989.0, 989.0, 989.0, 990.0, 990.0, 990.0, 990.0, 991.0, 991.0, 991.0, 992.0, 993.0, 993.0, 993.0, 993.0, 994.0, 994.0, 995.0, 995.0, 995.0, 996.0, 996.0, 996.0, 996.0, 997.0, 997.0, 997.0, 997.0, 998.0, 998.0, 998.0, 999.0, 999.0, 999.0, 1000.0, 1000.0, 1000.0, 1000.0, 1001.0, 1001.0, 1001.0, 1002.0, 1002.0, 1002.0, 1003.0, 1003.0, 1003.0, 1003.0, 1003.0, 1003.0, 1003.0, 1003.0, 1003.0, 1003.0, 1003.0, 1003.0, 1003.0, 1003.0, 1002.0, 1002.0, 1002.0, 1002.0, 1002.0, 1002.0, 1001.0, 1001.0, 1001.0, 1000.0, 1000.0, 1000.0, 999.0, 999.0, 998.0, 998.0, 997.0, 997.0, 996.0, 995.0, 995.0, 994.0, 993.0, 993.0, 992.0, 991.0, 991.0, 990.0 
#> [parseValues] Parsing field AthmosphericPressure AthmosphericPressure hPa 
#> [parseValues] Using converter:
#> NULL
#> [parseValues] Using converter function:
#> function (x, sos) 
#> {
#>     return(as.double(x = x))
#> }
#> <bytecode: 0x563f8fb71f18>
#> <environment: namespace:sos4R>
#> [parseValues] Binding additional data.frame for AthmosphericPressure -- value range 989, 1003 
#> [parseValues] Added column name: AthmosphericPressure 
#> [parseValues] The new bound data frame (one variable the a temp id):
#> 'data.frame':    144 obs. of  3 variables:
#>  $ tempID              : int  1 2 3 4 5 6 7 8 9 10 ...
#>  $ phenomenonTime      : POSIXct, format: "2018-01-01 00:30:00" "2018-01-01 00:45:00" ...
#>  $ AthmosphericPressure: num  990 990 990 990 990 990 990 990 990 990 ...
#> [parseValues] Added attributes to new data: AthmosphericPressure, AthmosphericPressure, hPa [ names:  name, definition, unit of measurement ] 
#> [parseValues] Old attributes list is  
#> [parseValues] New attributes list is AthmosphericPressure, AthmosphericPressure, hPa 
#> [parseValues] Removing temporary first column
#> [parseValues] returning final data frame:
#> 'data.frame':    144 obs. of  2 variables:
#>  $ phenomenonTime      : POSIXct, format: "2018-01-01 00:30:00" "2018-01-01 00:45:00" ...
#>  $ AthmosphericPressure: num  990 990 990 990 990 990 990 990 990 990 ...
#>   ..- attr(*, "name")= chr "AthmosphericPressure"
#>   ..- attr(*, "definition")= chr "AthmosphericPressure"
#>   ..- attr(*, "unit of measurement")= chr "hPa"
#> [parseResult] Done
#> [parseTime] Entering
#> [parseTime] Found time instant
#> [parseTime] Done: GmlTimePosition [ time: 2018-01-01 01:00:00 ] 
#> [parseOM] Done parsing
#> [parseOM] Done parsing
#> [parseObservationCollection] Done. Processed 1 elements: ws2500_AthmosphericPressure_sf_6CDEBFA1EC9556CF0D23CC12569D98D2F2771C72 
#> [parseOM] Done parsing
#> [.getObservationById_1.0.0] Got OmObservationCollection ... calculating length with sosResult()[.getObservationById_1.0.0] result:  list(phenomenonTime = c(1514763000, 1514763900, 1514764800, 1514766600, 1514767500, 1514768400, 1514770200, 1514771100, 1514772000, 1514773800, 1514774700, 1514775600, 1514777400, 1514778300, 1514779200, 1514781000, 1514781900, 1514783700, 1514784600, 1514785500, 1514786400, 1514788200, 1514789100, 1514790000, 1514791800, 1514792700, 1514793600, 1514795400, 1514796300, 1514797200, 1514799000, 1514799900, 1514800800, 1514802600, 1514803500, 1514804400, 1514806200, 1514807100, 1514808000, 1514809800, 
#> 1514810700, 1514811600, 1514813400, 1514814300, 1514815200, 1514817000, 1514817900, 1514818800, 1514820600, 1514821500, 1514822400, 1514824200, 1514825100, 1514826000, 1514827800, 1514828700, 1514829600, 1514831400, 1514832300, 1514833200, 1514835000, 1514835900, 1514836800, 1514838600, 1514839500, 1514840400, 1514842200, 1514843100, 1514844000, 1514845800, 1514846700, 1514847600, 1514849400, 1514850300, 1514851200, 1514853000, 1514853900, 1514854800, 1514856600, 1514857500, 1514858400, 1514860200, 
#> 1514861100, 1514862000, 1514863800, 1514864700, 1514865600, 1514867400, 1514868300, 1514870100, 1514871000, 1514871900, 1514872800, 1514874600, 1514875500, 1514876400, 1514878200, 1514879100, 1514880000, 1514881800, 1514882700, 1514883600, 1514885400, 1514886300, 1514887200, 1514889000, 1514889900, 1514890800, 1514892600, 1514893500, 1514894400, 1514896200, 1514897100, 1514898000, 1514899800, 1514900700, 1514901600, 1514903400, 1514904300, 1514905200, 1514907000, 1514907900, 1514908800, 1514910600, 
#> 1514911500, 1514912400, 1514914200, 1514915100, 1514916000, 1514917800, 1514918700, 1514919600, 1514921400, 1514922300, 1514923200, 1514925000, 1514925900, 1514926800, 1514928600, 1514929500, 1514930400, 1514932200, 1514933100, 1514934000), AthmosphericPressure = c(990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 990, 991, 991, 991, 992, 992, 992, 993, 993, 993, 994, 994, 994, 994, 994, 994, 995, 995, 995, 994, 994, 994, 994, 994, 993, 993, 993, 993, 992, 992, 992, 991, 991, 991, 991, 990, 
#> 990, 990, 990, 990, 990, 990, 990, 989, 989, 989, 989, 989, 989, 989, 990, 990, 990, 990, 991, 991, 991, 992, 993, 993, 993, 993, 994, 994, 995, 995, 995, 996, 996, 996, 996, 997, 997, 997, 997, 998, 998, 998, 999, 999, 999, 1000, 1000, 1000, 1000, 1001, 1001, 1001, 1002, 1002, 1002, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1003, 1002, 1002, 1002, 1002, 1002, 1002, 1001, 1001, 1001, 1000, 1000, 1000, 999, 999, 998, 998, 997, 997, 996, 995, 995, 994, 993, 993, 
#> 992, 991, 991, 990))[.getObservation_1.0.0] PARSED RESPONSE: OmObservationCollection 
#> [.getObservation_1.0.0] Result length(s):  144 
#> [sos4R] Finished getObservation to http://sensorweb.demo.52north.org/sensorwebtestbed/service/kvp 
#>  --> received 1 observation(s) having 144 result values [ 144 ].
#> Object of class OmObservationCollection with 1 members.

By using verboseOutput you can also debug the automatic GetCapabilities operation when creating a new SOS connection. That output is too extensive to show within this document.

verboseSOS <- SOS(sosUrl(mySOS),
                  verboseOutput = TRUE,
                  binding = sosBinding(mySOS),
                  dcpFilter = mySOS@dcpFilter)

Support

Feel free to ask questions about using the software or report a bug at the project issue tracker: https://github.com/52North/sos4R/issues. There you can also find existing bug reports and planned features.

Acknowledgements

The start of the project was generously supported by the 52°North Student Innovation Prize for Geoinformatics 2010. Thanks go also to Edzer Pebesma for contributing analyses to the demos at an early stage.

Outlook

In future releases a tighter integration is planned with the sf package regarding output data structures and classes.

References