eblondel / ows4R

R Interface for OGC Web-Services (OWS)

Home Page:https://eblondel.github.io/ows4R/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Parsing coverageDescription information

annakrystalli opened this issue Β· comments

Hi @eblondel πŸ‘‹

I've started development on the EMODnetWCS package and am trying to write the function to compile metadata on each coverage into a more usable format for R users. I'm having trouble figuring out how to extract information from the return gml objects. For example, see an extention of the vliz example below:

library(ows4R)
#> Loading required package: geometa
#> Loading ISO 19139 XML schemas...
#> Loading ISO 19115 codelists...
#> Loading IANA mime types...
#> No encoding supplied: defaulting to UTF-8.
#> Loading required package: keyring
vliz <- WCSClient$new(url = "https://geo.vliz.be/geoserver/wcs", serviceVersion = "2.0.1", logger = "DEBUG")
#> [ows4R][INFO] OWSGetCapabilities - Fetching https://geo.vliz.be/geoserver/wcs?service=WCS&version=2.0.1&request=GetCapabilities
cov <- vliz$getCapabilities()$findCoverageSummaryById("Emodnetbio__aca_spp_19582016_L1", exact = TRUE)
cov_des <- cov$getDescription()
#> [ows4R][INFO] WCSDescribeCoverage - Fetching https://geo.vliz.be/geoserver/wcs?service=WCS&version=2.0.1&coverageId=Emodnetbio__aca_spp_19582016_L1&request=DescribeCoverage
#> Loading required package: sf
#> Linking to GEOS 3.9.1, GDAL 3.4.0, PROJ 8.1.1; sf_use_s2() is TRUE
cov_des$metadata
#> <GMLCOVExtension>
#> ....|-- TimeDomain <WCSGSTimeDomain>
#> ........|-- TimeInstant: 1958-02-16T00:00:00.000Z
#> ........|-- TimeInstant: 1958-05-16T00:00:00.000Z
#> ........|-- TimeInstant: 1958-08-16T00:00:00.000Z
#> ........|-- TimeInstant: 1958-11-16T00:00:00.000Z
#> ........|-- TimeInstant: 1959-02-16T00:00:00.000Z
#> ........|-- TimeInstant: 1959-05-16T00:00:00.000Z
#> ........|-- TimeInstant: 1959-08-16T00:00:00.000Z
#> ........|-- TimeInstant: 1959-11-16T00:00:00.000Z
#> ........|-- TimeInstant: 1960-02-16T00:00:00.000Z
#> ........|-- TimeInstant: 1960-05-16T00:00:00.000Z
#> ........|-- TimeInstant: 1960-08-16T00:00:00.000Z
#> ........|-- TimeInstant: 1960-11-16T00:00:00.000Z
#> ........|-- TimeInstant: 1961-02-16T00:00:00.000Z
#> ........|-- TimeInstant: 1961-05-16T00:00:00.000Z
#> ........|-- TimeInstant: 1961-08-16T00:00:00.000Z
#> ........|-- TimeInstant: 1961-11-16T00:00:00.000Z
#> ........|-- TimeInstant: 1962-02-16T00:00:00.000Z
#> ........|-- TimeInstant: 1962-05-16T00:00:00.000Z
#> ........|-- TimeInstant: 1962-08-16T00:00:00.000Z
#> ........|-- TimeInstant: 1962-11-16T00:00:00.000Z
#> ........|-- TimeInstant: 1963-02-16T00:00:00.000Z
#> ........|-- TimeInstant: 1963-05-16T00:00:00.000Z
#> ........|-- TimeInstant: 1963-08-16T00:00:00.000Z
#> ........|-- TimeInstant: 1963-11-16T00:00:00.000Z
#> ........|-- TimeInstant: 1964-02-16T00:00:00.000Z
#> ........|-- TimeInstant: 1964-05-16T00:00:00.000Z
#> ........|-- TimeInstant: 1964-08-16T00:00:00.000Z
#> ........|-- TimeInstant: 1964-11-16T00:00:00.000Z
#> ........|-- TimeInstant: 1965-02-16T00:00:00.000Z
#> ........|-- TimeInstant: 1965-05-16T00:00:00.000Z
#> ........|-- TimeInstant: 1965-08-16T00:00:00.000Z
#> ........|-- TimeInstant: 1965-11-16T00:00:00.000Z
#> ........|-- TimeInstant: 1966-02-16T00:00:00.000Z
#> ........|-- TimeInstant: 1966-05-16T00:00:00.000Z
#> ........|-- TimeInstant: 1966-08-16T00:00:00.000Z
#> ........|-- TimeInstant: 1966-11-16T00:00:00.000Z
#> ........|-- TimeInstant: 1967-02-16T00:00:00.000Z
#> ........|-- TimeInstant: 1967-05-16T00:00:00.000Z
#> ........|-- TimeInstant: 1967-08-16T00:00:00.000Z
#> ........|-- TimeInstant: 1967-11-16T00:00:00.000Z
#> ........|-- TimeInstant: 1968-02-16T00:00:00.000Z
#> ........|-- TimeInstant: 1968-05-16T00:00:00.000Z
#> ........|-- TimeInstant: 1968-08-16T00:00:00.000Z
#> ........|-- TimeInstant: 1968-11-16T00:00:00.000Z
#> ........|-- TimeInstant: 1969-02-16T00:00:00.000Z
#> ........|-- TimeInstant: 1969-05-16T00:00:00.000Z
#> ........|-- TimeInstant: 1969-08-16T00:00:00.000Z
#> ........|-- TimeInstant: 1969-11-16T00:00:00.000Z
#> ........|-- TimeInstant: 1970-02-16T00:00:00.000Z
#> ........|-- TimeInstant: 1970-05-16T00:00:00.000Z
#> ........|-- TimeInstant: 1970-08-16T00:00:00.000Z
#> ........|-- TimeInstant: 1970-11-16T00:00:00.000Z
#> ........|-- TimeInstant: 1971-02-16T00:00:00.000Z
#> ........|-- TimeInstant: 1971-05-16T00:00:00.000Z
#> ........|-- TimeInstant: 1971-08-16T00:00:00.000Z
#> ........|-- TimeInstant: 1971-11-16T00:00:00.000Z
#> ........|-- TimeInstant: 1972-02-16T00:00:00.000Z
#> ........|-- TimeInstant: 1972-05-16T00:00:00.000Z
#> ........|-- TimeInstant: 1972-08-16T00:00:00.000Z
#> ........|-- TimeInstant: 1972-11-16T00:00:00.000Z
#> ........|-- TimeInstant: 1973-02-16T00:00:00.000Z
#> ........|-- TimeInstant: 1973-05-16T00:00:00.000Z
#> ........|-- TimeInstant: 1973-08-16T00:00:00.000Z
#> ........|-- TimeInstant: 1973-11-16T00:00:00.000Z
#> ........|-- TimeInstant: 1974-02-16T00:00:00.000Z
#> ........|-- TimeInstant: 1974-05-16T00:00:00.000Z
#> ........|-- TimeInstant: 1974-08-16T00:00:00.000Z
#> ........|-- TimeInstant: 1974-11-16T00:00:00.000Z
#> ........|-- TimeInstant: 1975-02-16T00:00:00.000Z
#> ........|-- TimeInstant: 1975-05-16T00:00:00.000Z
#> ........|-- TimeInstant: 1975-08-16T00:00:00.000Z
#> ........|-- TimeInstant: 1975-11-16T00:00:00.000Z
#> ........|-- TimeInstant: 1976-02-16T00:00:00.000Z
#> ........|-- TimeInstant: 1976-05-16T00:00:00.000Z
#> ........|-- TimeInstant: 1976-08-16T00:00:00.000Z
#> ........|-- TimeInstant: 1976-11-16T00:00:00.000Z
#> ........|-- TimeInstant: 1977-02-16T00:00:00.000Z
#> ........|-- TimeInstant: 1977-05-16T00:00:00.000Z
#> ........|-- TimeInstant: 1977-08-16T00:00:00.000Z
#> ........|-- TimeInstant: 1977-11-16T00:00:00.000Z
#> ........|-- TimeInstant: 1978-02-16T00:00:00.000Z
#> ........|-- TimeInstant: 1978-05-16T00:00:00.000Z
#> ........|-- TimeInstant: 1978-08-16T00:00:00.000Z
#> ........|-- TimeInstant: 1978-11-16T00:00:00.000Z
#> ........|-- TimeInstant: 1979-02-16T00:00:00.000Z
#> ........|-- TimeInstant: 1979-05-16T00:00:00.000Z
#> ........|-- TimeInstant: 1979-08-16T00:00:00.000Z
#> ........|-- TimeInstant: 1979-11-16T00:00:00.000Z
#> ........|-- TimeInstant: 1980-02-16T00:00:00.000Z
#> ........|-- TimeInstant: 1980-05-16T00:00:00.000Z
#> ........|-- TimeInstant: 1980-08-16T00:00:00.000Z
#> ........|-- TimeInstant: 1980-11-16T00:00:00.000Z
#> ........|-- TimeInstant: 1981-02-16T00:00:00.000Z
#> ........|-- TimeInstant: 1981-05-16T00:00:00.000Z
#> ........|-- TimeInstant: 1981-08-16T00:00:00.000Z
#> ........|-- TimeInstant: 1981-11-16T00:00:00.000Z
#> ........|-- TimeInstant: 1982-02-16T00:00:00.000Z
#> ........|-- TimeInstant: 1982-05-16T00:00:00.000Z
#> ........|-- TimeInstant: 1982-08-16T00:00:00.000Z
#> ........|-- TimeInstant: 1982-11-16T00:00:00.000Z
#> ........|-- TimeInstant: 1983-02-16T00:00:00.000Z
#> ........|-- TimeInstant: 1983-05-16T00:00:00.000Z
#> ........|-- TimeInstant: 1983-08-16T00:00:00.000Z
#> ........|-- TimeInstant: 1983-11-16T00:00:00.000Z
#> ........|-- TimeInstant: 1984-02-16T00:00:00.000Z
#> ........|-- TimeInstant: 1984-05-16T00:00:00.000Z
#> ........|-- TimeInstant: 1984-08-16T00:00:00.000Z
#> ........|-- TimeInstant: 1984-11-16T00:00:00.000Z
#> ........|-- TimeInstant: 1985-02-16T00:00:00.000Z
#> ........|-- TimeInstant: 1985-05-16T00:00:00.000Z
#> ........|-- TimeInstant: 1985-08-16T00:00:00.000Z
#> ........|-- TimeInstant: 1985-11-16T00:00:00.000Z
#> ........|-- TimeInstant: 1986-02-16T00:00:00.000Z
#> ........|-- TimeInstant: 1986-05-16T00:00:00.000Z
#> ........|-- TimeInstant: 1986-08-16T00:00:00.000Z
#> ........|-- TimeInstant: 1986-11-16T00:00:00.000Z
#> ........|-- TimeInstant: 1987-02-16T00:00:00.000Z
#> ........|-- TimeInstant: 1987-05-16T00:00:00.000Z
#> ........|-- TimeInstant: 1987-08-16T00:00:00.000Z
#> ........|-- TimeInstant: 1987-11-16T00:00:00.000Z
#> ........|-- TimeInstant: 1988-02-16T00:00:00.000Z
#> ........|-- TimeInstant: 1988-05-16T00:00:00.000Z
#> ........|-- TimeInstant: 1988-08-16T00:00:00.000Z
#> ........|-- TimeInstant: 1988-11-16T00:00:00.000Z
#> ........|-- TimeInstant: 1989-02-16T00:00:00.000Z
#> ........|-- TimeInstant: 1989-05-16T00:00:00.000Z
#> ........|-- TimeInstant: 1989-08-16T00:00:00.000Z
#> ........|-- TimeInstant: 1989-11-16T00:00:00.000Z
#> ........|-- TimeInstant: 1990-02-16T00:00:00.000Z
#> ........|-- TimeInstant: 1990-05-16T00:00:00.000Z
#> ........|-- TimeInstant: 1990-08-16T00:00:00.000Z
#> ........|-- TimeInstant: 1990-11-16T00:00:00.000Z
#> ........|-- TimeInstant: 1991-02-16T00:00:00.000Z
#> ........|-- TimeInstant: 1991-05-16T00:00:00.000Z
#> ........|-- TimeInstant: 1991-08-16T00:00:00.000Z
#> ........|-- TimeInstant: 1991-11-16T00:00:00.000Z
#> ........|-- TimeInstant: 1992-02-16T00:00:00.000Z
#> ........|-- TimeInstant: 1992-05-16T00:00:00.000Z
#> ........|-- TimeInstant: 1992-08-16T00:00:00.000Z
#> ........|-- TimeInstant: 1992-11-16T00:00:00.000Z
#> ........|-- TimeInstant: 1993-02-16T00:00:00.000Z
#> ........|-- TimeInstant: 1993-05-16T00:00:00.000Z
#> ........|-- TimeInstant: 1993-08-16T00:00:00.000Z
#> ........|-- TimeInstant: 1993-11-16T00:00:00.000Z
#> ........|-- TimeInstant: 1994-02-16T00:00:00.000Z
#> ........|-- TimeInstant: 1994-05-16T00:00:00.000Z
#> ........|-- TimeInstant: 1994-08-16T00:00:00.000Z
#> ........|-- TimeInstant: 1994-11-16T00:00:00.000Z
#> ........|-- TimeInstant: 1995-02-16T00:00:00.000Z
#> ........|-- TimeInstant: 1995-05-16T00:00:00.000Z
#> ........|-- TimeInstant: 1995-08-16T00:00:00.000Z
#> ........|-- TimeInstant: 1995-11-16T00:00:00.000Z
#> ........|-- TimeInstant: 1996-02-16T00:00:00.000Z
#> ........|-- TimeInstant: 1996-05-16T00:00:00.000Z
#> ........|-- TimeInstant: 1996-08-16T00:00:00.000Z
#> ........|-- TimeInstant: 1996-11-16T00:00:00.000Z
#> ........|-- TimeInstant: 1997-02-16T00:00:00.000Z
#> ........|-- TimeInstant: 1997-05-16T00:00:00.000Z
#> ........|-- TimeInstant: 1997-08-16T00:00:00.000Z
#> ........|-- TimeInstant: 1997-11-16T00:00:00.000Z
#> ........|-- TimeInstant: 1998-02-16T00:00:00.000Z
#> ........|-- TimeInstant: 1998-05-16T00:00:00.000Z
#> ........|-- TimeInstant: 1998-08-16T00:00:00.000Z
#> ........|-- TimeInstant: 1998-11-16T00:00:00.000Z
#> ........|-- TimeInstant: 1999-02-16T00:00:00.000Z
#> ........|-- TimeInstant: 1999-05-16T00:00:00.000Z
#> ........|-- TimeInstant: 1999-08-16T00:00:00.000Z
#> ........|-- TimeInstant: 1999-11-16T00:00:00.000Z
#> ........|-- TimeInstant: 2000-02-16T00:00:00.000Z
#> ........|-- TimeInstant: 2000-05-16T00:00:00.000Z
#> ........|-- TimeInstant: 2000-08-16T00:00:00.000Z
#> ........|-- TimeInstant: 2000-11-16T00:00:00.000Z
#> ........|-- TimeInstant: 2001-02-16T00:00:00.000Z
#> ........|-- TimeInstant: 2001-05-16T00:00:00.000Z
#> ........|-- TimeInstant: 2001-08-16T00:00:00.000Z
#> ........|-- TimeInstant: 2001-11-16T00:00:00.000Z
#> ........|-- TimeInstant: 2002-02-16T00:00:00.000Z
#> ........|-- TimeInstant: 2002-05-16T00:00:00.000Z
#> ........|-- TimeInstant: 2002-08-16T00:00:00.000Z
#> ........|-- TimeInstant: 2002-11-16T00:00:00.000Z
#> ........|-- TimeInstant: 2003-02-16T00:00:00.000Z
#> ........|-- TimeInstant: 2003-05-16T00:00:00.000Z
#> ........|-- TimeInstant: 2003-08-16T00:00:00.000Z
#> ........|-- TimeInstant: 2003-11-16T00:00:00.000Z
#> ........|-- TimeInstant: 2004-02-16T00:00:00.000Z
#> ........|-- TimeInstant: 2004-05-16T00:00:00.000Z
#> ........|-- TimeInstant: 2004-08-16T00:00:00.000Z
#> ........|-- TimeInstant: 2004-11-16T00:00:00.000Z
#> ........|-- TimeInstant: 2005-02-16T00:00:00.000Z
#> ........|-- TimeInstant: 2005-05-16T00:00:00.000Z
#> ........|-- TimeInstant: 2005-08-16T00:00:00.000Z
#> ........|-- TimeInstant: 2005-11-16T00:00:00.000Z
#> ........|-- TimeInstant: 2006-02-16T00:00:00.000Z
#> ........|-- TimeInstant: 2006-05-16T00:00:00.000Z
#> ........|-- TimeInstant: 2006-08-16T00:00:00.000Z
#> ........|-- TimeInstant: 2006-11-16T00:00:00.000Z
#> ........|-- TimeInstant: 2007-02-16T00:00:00.000Z
#> ........|-- TimeInstant: 2007-05-16T00:00:00.000Z
#> ........|-- TimeInstant: 2007-08-16T00:00:00.000Z
#> ........|-- TimeInstant: 2007-11-16T00:00:00.000Z
#> ........|-- TimeInstant: 2008-02-16T00:00:00.000Z
#> ........|-- TimeInstant: 2008-05-16T00:00:00.000Z
#> ........|-- TimeInstant: 2008-08-16T00:00:00.000Z
#> ........|-- TimeInstant: 2008-11-16T00:00:00.000Z
#> ........|-- TimeInstant: 2009-02-16T00:00:00.000Z
#> ........|-- TimeInstant: 2009-05-16T00:00:00.000Z
#> ........|-- TimeInstant: 2009-08-16T00:00:00.000Z
#> ........|-- TimeInstant: 2009-11-16T00:00:00.000Z
#> ........|-- TimeInstant: 2010-02-16T00:00:00.000Z
#> ........|-- TimeInstant: 2010-05-16T00:00:00.000Z
#> ........|-- TimeInstant: 2010-08-16T00:00:00.000Z
#> ........|-- TimeInstant: 2010-11-16T00:00:00.000Z
#> ........|-- TimeInstant: 2011-02-16T00:00:00.000Z
#> ........|-- TimeInstant: 2011-05-16T00:00:00.000Z
#> ........|-- TimeInstant: 2011-08-16T00:00:00.000Z
#> ........|-- TimeInstant: 2011-11-16T00:00:00.000Z
#> ........|-- TimeInstant: 2012-02-16T00:00:00.000Z
#> ........|-- TimeInstant: 2012-05-16T00:00:00.000Z
#> ........|-- TimeInstant: 2012-08-16T00:00:00.000Z
#> ........|-- TimeInstant: 2012-11-16T00:00:00.000Z
#> ........|-- TimeInstant: 2013-02-16T00:00:00.000Z
#> ........|-- TimeInstant: 2013-05-16T00:00:00.000Z
#> ........|-- TimeInstant: 2013-08-16T00:00:00.000Z
#> ........|-- TimeInstant: 2013-11-16T00:00:00.000Z
#> ........|-- TimeInstant: 2014-02-16T00:00:00.000Z
#> ........|-- TimeInstant: 2014-05-16T00:00:00.000Z
#> ........|-- TimeInstant: 2014-08-16T00:00:00.000Z
#> ........|-- TimeInstant: 2014-11-16T00:00:00.000Z
#> ........|-- TimeInstant: 2015-02-16T00:00:00.000Z
#> ........|-- TimeInstant: 2015-05-16T00:00:00.000Z
#> ........|-- TimeInstant: 2015-08-16T00:00:00.000Z
#> ........|-- TimeInstant: 2015-11-16T00:00:00.000Z
#> ........|-- TimeInstant: 2016-02-16T00:00:00.000Z
#> ........|-- TimeInstant: 2016-05-16T00:00:00.000Z
#> ........|-- TimeInstant: 2016-08-16T00:00:00.000Z
#> ........|-- TimeInstant: 2016-11-16T00:00:00.000Z
#> ....|-- DimensionDomain <ISOElementSequence>
#> ........|-- SingleValue: 4
cov_des$rangeType$DataRecord
#> <GMLElement>
#> ....|-- field <GMLElement>
#> ........|-- Quantity <GMLElement>
#> ............|-- description <GMLElement>
#> ................|-- value: relative_abundance
#> ............|-- nilValues <GMLElement>
#> ................|-- NilValues <GMLElement>
#> ....................|-- nilValue <GMLElement>
#> ........................|-- value: 9.969209968386869E36
#> ............|-- uom <GMLElement>
#> ............|-- constraint <GMLElement>
#> ................|-- AllowedValues <GMLElement>
#> ....................|-- interval <GMLElement>
#> ........................|-- value: -3.4028235E38 3.4028235E38

Created on 2022-08-02 by the reprex package (v2.0.1)

So for example, how can I extract the description and interval from the rangeType$DataRecord object?

It would be useful to add a few examples to the documentation also.

I've also tried to use the functions in the WCSCoverageDescription but I only get useful output from getId().

library(ows4R)
#> Loading required package: geometa
#> Loading ISO 19139 XML schemas...
#> Loading ISO 19115 codelists...
#> Loading IANA mime types...
#> No encoding supplied: defaulting to UTF-8.
#> Loading required package: keyring
library(terra)
#> terra 1.5.21
vliz <- WCSClient$new(url = "https://geo.vliz.be/geoserver/wcs", serviceVersion = "2.0.1", logger = "DEBUG")
#> [ows4R][INFO] OWSGetCapabilities - Fetching https://geo.vliz.be/geoserver/wcs?service=WCS&version=2.0.1&request=GetCapabilities
cov <- vliz$getCapabilities()$findCoverageSummaryById("Emodnetbio__aca_spp_19582016_L1", exact = TRUE)
cov_des <- cov$getDescription()
#> [ows4R][INFO] WCSDescribeCoverage - Fetching https://geo.vliz.be/geoserver/wcs?service=WCS&version=2.0.1&coverageId=Emodnetbio__aca_spp_19582016_L1&request=DescribeCoverage
#> Loading required package: sf
#> Linking to GEOS 3.9.1, GDAL 3.4.0, PROJ 8.1.1; sf_use_s2() is TRUE
cov_des$getId()
#> [1] "Emodnetbio__aca_spp_19582016_L1"
cov_des$getRange()
#> list()
cov_des$getDomain()
#> list()
cov_des$getSupportedFormats()
#> list()

Created on 2022-08-02 by the reprex package (v2.0.1)

@annakrystalli Here we deal with differences between WCS standard versions. The methods you try to query are specific to WCS version 1.x , so querying a WCS 2.0.1 it's totally normal you get empty lists:

  • getDomain() and getSupportedFormats() are implemented in ows4R but target WCS version 1
  • getRange() with range XML parsing is not yet implemented in ows4R, it targets WCS version 1.0

In ows4R, to deal with this heterogeneity of how dimensions are handled depending on WCS version and also the complexity of WCS standard when relying on GML COV bindings, i've implemented a method cov$getDimensions() that gives you the dimensions of your coverage. This is particularly useful for time / elevation values.

In general base objects (that come from geometa if not belonging to OGC web service standards ) are R6 objects that you can query as lists with '$' , which can give a first way to extract values.

There is not yet similar easy function to extract data characteristics (rangeType / swe:DataRecord). In the XML, you will see these elements belong to the swe namespace, which deals with the OGC Sensor Web Enablement (SWE) standard. The main reason why there is no function to get properly this data record is because OGC SWE is not yet implemented through base bindings in geometa, although i've started looking into it already.

Last but not least, in WCS 2.x servers, let me add that a coverage description is not defined anymore in the WCS standard specification, but in the GML COV standard, which is also handled (as GML bindings extension) in geometa.

You can see here the full inventory of bindings implemented and to be implemented. I've recently added SWE as standard to cover, and started adding some SWE bindings.

Thanks for the info @eblondel ! Very helpful