Coder Social home page Coder Social logo

ows4r's Introduction

Build Status CRAN_Status_Badge cran checks Github_Status_Badge DOI

ows4R – R Interface to OGC Web-Services (OWS)

ows4R provides an Interface to Web-Services defined as open standards by the Open Geospatial Consortium (OGC), including Web Feature Service (WFS) for vector data, Web Coverage Service (WCS), Catalogue Service (CSW) for ISO/OGC metadata, Web Processing Service (WPS) for data processes, and associated standards such as the common web-service specification (OWS) and OGC Filter Encoding. Partial support is provided for the Web Map Service (WMS). The purpose is to add support for additional OGC service standards such as Web Coverage Processing Service (WCPS), the Sensor Observation Service (SOS), or even new standard services emerging such OGC API or SensorThings.

It currently targets:

  • the Common OGC Web-Services specifications, versions 1.1 and 2.0
  • the Catalogue Service for the Web (CSW), version 2.0.2 (including Transaction and Harvest operations)
  • the Web Feature Service (WFS), versions 1.0.0, 1.1.0, and 2.0.0
  • the Web Coverage Service (WCS), versions 1.0, 1.1.0, 1.1.1, 2.0.1 and 2.1.0
  • the Web Map Service (WMS), versions 1.1.0, 1.1.1, and 1.3.0
  • the Web Processing service (WPS) version 1.0.0

Do you have a question? support request? you can create a 'discussion' here

Sponsors

The following projects have contributed to strenghten ows4R:

  • for core, WFS and CSW support
  • for WMS and WPS support

Blue-Cloud has received funding from the European Union's Horizon programme call BG-07-2019-2020, topic: [A] 2019 - Blue Cloud services, Grant Agreement No.862409.

  • for the WCS support

Citation

We thank in advance people that use ows4R for citing it in their work / publication(s). For this, please use the citation provided at this link DOI

OGC standards coverage status

Standard Description Supported versions Unsupported versions Supported R bindings Support
OGC Filter Filter Encoding 1.1.0 2.0 ongoing
OGC Common Web Service Common 1.1,2.0 ongoing
OGC CSW Catalogue Service 2.0.2 3.0.0 geometa (ISO 19115 / 19119 / 19110 / 19139 XML) ongoing - seeking sponsors
OGC WFS Web Feature Service 1.0.0,1.1.0,2.0.0 sf (OGC Simple Feature) ongoing
OGC WMS Web Map Service 1.1.0,1.1.1,1.3.0 sf (OGC Simple Feature - for GetFeatureInfo operation) ongoing
OGC WCS Web Coverage Service 1.0.0, 1.1.0, 1.1.1, 2.0.1, 2.1.0 terra ongoing
OGC WPS Web Processing Service 1.0.0 2.0 under development (contribs welcome)
OGC SOS Sensor Observation Service 1.0,2.0 under investigation - seeking sponsors

In case of a missing feature, create a ticket.

Development perspectives

Support for additional OGC web-service standard specifications including:

  • Web Coverage Processing Service (WCPS)
  • Filter Encoding (FES) version 2.0
  • Web Feature Service (WFS) Transaction operations
  • Catalogue Service (CSW) version 3.0 (including Transaction and Harvest operations)
  • OGC API
  • ...

For more information, or if you are interested in funding this R project or to contribute to it, do not hesitate to contact me by e-mail

ows4r's People

Contributors

abennici avatar dfriend21 avatar eblondel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

ows4r's Issues

WFS - add encoding facilities for cql_filter and filter params

The purpose of this enhancement is to facilitate the use of filtering params in WFS:

  • cql_filter: In most of cases this filter needs to be URL-encoded. By adding this, we avoid the user to specify URLencode by (him/her)self.

wfs$getFeatures(cql_filter = "property = 'value'")

instead of

wfs$getFeatures(cql_filter = URLencode("property = 'value'"))

  • filter: Same as above we need to add URLencode, but in addition here more can be added to facilitate user's life. Indeed this parameter is supposed to receive OGC filter encoded as text/xml. ows4R provides bindings to generate these filters, eg.

OGCFilter$new( PropertyIsEqualTo$new("property", "value") )

Encoding to xml requires $encode() to the filter. A user that wants to specify such a filter will have to encode it, coerce it to character and URL-encode it. This is too much, and all this should be done transparently by ows4R.

wfs$getFeatures(filter = OGCFilter$new( PropertyIsEqualTo$new("property", "value") ))

instead of

wfs$getFeatures(filter = URLencode(as(OGCFilter$new( PropertyIsEqualTo$new("property", "value") )$encode(), "character")))

warning about deprecated syntax of proj4strings

library(ows4R)
#> Loading required package: geometa
#> Loading ISO 19139 XML schemas...
#> Loading ISO 19115 codelists...
wfs_bwk <- "https://geoservices.informatievlaanderen.be/overdrachtdiensten/BWK/wfs"
bwk_client <- WFSClient$new(wfs_bwk, 
                            serviceVersion = "2.0.0")
#> Warning in CPL_crs_from_input(x): GDAL Message 1: +init=epsg:XXXX syntax is
#> deprecated. It might return a CRS with a non-EPSG compliant axis order.

Created on 2021-01-13 by the reprex package (v0.3.0)

Session info
devtools::session_info()
#> - Session info ---------------------------------------------------------------
#>  setting  value                       
#>  version  R version 4.0.2 (2020-06-22)
#>  os       Windows 7 x64 SP 1          
#>  system   x86_64, mingw32             
#>  ui       RTerm                       
#>  language (EN)                        
#>  collate  Dutch_Belgium.1252          
#>  ctype    Dutch_Belgium.1252          
#>  tz       Europe/Paris                
#>  date     2021-01-13                  
#> 
#> - Packages -------------------------------------------------------------------
#>  package     * version  date       lib source        
#>  askpass       1.1      2019-01-13 [1] CRAN (R 4.0.0)
#>  assertthat    0.2.1    2019-03-21 [1] CRAN (R 4.0.0)
#>  callr         3.5.1    2020-10-13 [1] CRAN (R 4.0.3)
#>  class         7.3-17   2020-04-26 [2] CRAN (R 4.0.2)
#>  classInt      0.4-3    2020-04-07 [1] CRAN (R 4.0.0)
#>  cli           2.2.0    2020-11-20 [1] CRAN (R 4.0.3)
#>  crayon        1.3.4    2017-09-16 [1] CRAN (R 4.0.0)
#>  curl          4.3      2019-12-02 [1] CRAN (R 4.0.0)
#>  DBI           1.1.0    2019-12-15 [1] CRAN (R 4.0.0)
#>  desc          1.2.0    2018-05-01 [1] CRAN (R 4.0.0)
#>  devtools      2.3.1    2020-07-21 [1] CRAN (R 4.0.2)
#>  digest        0.6.27   2020-10-24 [1] CRAN (R 4.0.3)
#>  dplyr         1.0.2    2020-08-18 [1] CRAN (R 4.0.2)
#>  e1071         1.7-4    2020-10-14 [1] CRAN (R 4.0.3)
#>  ellipsis      0.3.1    2020-05-15 [1] CRAN (R 4.0.2)
#>  evaluate      0.14     2019-05-28 [1] CRAN (R 4.0.0)
#>  fansi         0.4.1    2020-01-08 [1] CRAN (R 4.0.0)
#>  fs            1.5.0    2020-07-31 [1] CRAN (R 4.0.2)
#>  generics      0.1.0    2020-10-31 [1] CRAN (R 4.0.3)
#>  geometa     * 0.6-3    2020-08-04 [1] CRAN (R 4.0.2)
#>  glue          1.4.2    2020-08-27 [1] CRAN (R 4.0.2)
#>  highr         0.8      2019-03-20 [1] CRAN (R 4.0.0)
#>  htmltools     0.5.0    2020-06-16 [1] CRAN (R 4.0.2)
#>  httr          1.4.2    2020-07-20 [1] CRAN (R 4.0.2)
#>  jsonlite      1.7.2    2020-12-09 [1] CRAN (R 4.0.3)
#>  KernSmooth    2.23-17  2020-04-26 [2] CRAN (R 4.0.2)
#>  knitr         1.30     2020-09-22 [1] CRAN (R 4.0.3)
#>  lattice       0.20-41  2020-04-02 [2] CRAN (R 4.0.2)
#>  lifecycle     0.2.0    2020-03-06 [1] CRAN (R 4.0.0)
#>  magrittr      2.0.1    2020-11-17 [1] CRAN (R 4.0.3)
#>  memoise       1.1.0    2017-04-21 [1] CRAN (R 4.0.0)
#>  openssl       1.4.3    2020-09-18 [1] CRAN (R 4.0.3)
#>  ows4R       * 0.1-5    2020-05-27 [1] CRAN (R 4.0.2)
#>  pillar        1.4.7    2020-11-20 [1] CRAN (R 4.0.3)
#>  pkgbuild      1.2.0    2020-12-15 [1] CRAN (R 4.0.2)
#>  pkgconfig     2.0.3    2019-09-22 [1] CRAN (R 4.0.0)
#>  pkgload       1.1.0    2020-05-29 [1] CRAN (R 4.0.2)
#>  prettyunits   1.1.1    2020-01-24 [1] CRAN (R 4.0.0)
#>  processx      3.4.5    2020-11-30 [1] CRAN (R 4.0.3)
#>  ps            1.5.0    2020-12-05 [1] CRAN (R 4.0.3)
#>  purrr         0.3.4    2020-04-17 [1] CRAN (R 4.0.0)
#>  R6            2.5.0    2020-10-28 [1] CRAN (R 4.0.3)
#>  Rcpp          1.0.5    2020-07-06 [1] CRAN (R 4.0.2)
#>  remotes       2.2.0    2020-07-21 [1] CRAN (R 4.0.2)
#>  rgdal         1.5-18   2020-10-13 [1] CRAN (R 4.0.3)
#>  rlang         0.4.9    2020-11-26 [1] CRAN (R 4.0.3)
#>  rmarkdown     2.4      2020-09-30 [1] CRAN (R 4.0.3)
#>  rprojroot     2.0.2    2020-11-15 [1] CRAN (R 4.0.3)
#>  sessioninfo   1.1.1    2018-11-05 [1] CRAN (R 4.0.0)
#>  sf            0.9-6    2020-09-13 [1] CRAN (R 4.0.3)
#>  sp            1.4-4    2020-10-07 [1] CRAN (R 4.0.3)
#>  stringi       1.5.3    2020-09-09 [1] CRAN (R 4.0.2)
#>  stringr       1.4.0    2019-02-10 [1] CRAN (R 4.0.0)
#>  testthat      3.0.0    2020-10-31 [1] CRAN (R 4.0.3)
#>  tibble        3.0.4    2020-10-12 [1] CRAN (R 4.0.3)
#>  tidyselect    1.1.0    2020-05-11 [1] CRAN (R 4.0.2)
#>  units         0.6-7    2020-06-13 [1] CRAN (R 4.0.2)
#>  usethis       1.6.1    2020-04-29 [1] CRAN (R 4.0.0)
#>  vctrs         0.3.5    2020-11-17 [1] CRAN (R 4.0.3)
#>  withr         2.2.0    2020-04-20 [1] CRAN (R 4.0.2)
#>  xfun          0.19     2020-10-30 [1] CRAN (R 4.0.3)
#>  XML           3.99-0.5 2020-07-23 [1] CRAN (R 4.0.2)
#>  yaml          2.2.1    2020-02-01 [1] CRAN (R 4.0.0)
#> 
#> [1] C:/R/Library
#> [2] C:/Program Files/R/R-4.0.2/library

The warning suggests that (non-GDAL3-compliant) proj4strings have been transmitted. They should be avoided, cf https://www.r-spatial.org/r/2020/03/17/wkt.html and e.g. https://geocompr.github.io/presentations/.

I'm not sure whether this is something that needs to be addressed in the ows4R package or somewhere deeper.

revdep of sf / s2 breaks ows4R

I see this

Package: ows4R
Check: examples
Old result: OK
New result: ERROR
  Running examples in ‘ows4R-Ex.R’ failed
  The error most likely occurred in:
  
  > base::assign(".ptime", proc.time(), pos = "CheckExEnv")
  > ### Name: BBOX
  > ### Title: BBOX
  > ### Aliases: BBOX
  > ### Keywords: BBOX Expression OGC
  > 
  > ### ** Examples
  > 
  >   bbox <- OWSUtils$toBBOX(-180,-90,180,90)
  >   expr <- BBOX$new(bbox)
  >   expr_xml <- expr$encode() #see how it looks like in XML
  Error in xmlSchemaValidate(xsd, xml) : 
    trying to get slot "ref" from an object of a basic class ("NULL") with no slots
  Calls: <Anonymous> -> <Anonymous> -> <Anonymous> -> xmlSchemaValidate
  Execution halted

when revdep checking ows4R using s2 (1.0.5, CRAN) and sf from github (branch sf_1_0); planning to submit this branch soon as sf 1.0 to CRAN. Let me know if we can help.

See r-spatial/sf#1649 for more info (and possibly help).

WFS paging support

Great work with this package!

It would be great if the WFS functionality would support paging.
Therefore, checking how many features are requested, what the per-request limit is, and iterate till all features are downloaded.

library(ows4R)
wfs <- WFSClient$new("https://geodata.nationaalgeoregister.nl/bag/wfs?", "2.0.0", logger = "DEBUG")
caps <- wfs$getCapabilities()

ft <- caps$findFeatureTypeByName("bag:pand")
ft$getDescription()`

sf <- ft$getFeatures(bbox = '110513.3,436371.4,174951.2,480440.6',resultType='hits')
getFeatures$resultType

This workaround to inform about the amount of features (resultType = 'hits') did not work, because the response of getFeatures is automatically coerced to a sf object, which renders an error since it contains no features.


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

mapping FeatureType datatypes fails with case sensitive datatypes

It sounds that datatypes are sometimes written as lowercase or camel case depending on the datasources (possibly depending on the back-end data store used behind the OGC services).

In the case of point 1 highlighted in #17, this prevents from fetching feature type description properly.

Marked primarily as bug because blocking user.

WFS (Web Feature Service) Client

Versions

  • 1.0.0
  • 1.1.0
  • 2.0.0

Operations

  • GetCapabilities (supported in ows4R 0.1)
  • DescribeFeatureType (supported in ows4R 0.1)
  • GetFeature (supported in ows4R 0.1)
  • LockFeature
  • Transaction

Operations in 2.0.0

  • GetPropertyValue
  • GetFeatureWithLock
  • CreateStoredQuery
  • DropStoredQuery
  • ListStoredQueries
  • DescribeStoredQueries

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

WCS (Web Coverage Service) Client

Versions

WCS version OWS version Supported
1.0.0 1.1 ongoing
1.1.0 1.1 ongoing
1.1.1 1.1 ongoing
2.0.1 2.0 ongoing
2.1.0 2.0 ongoing

Classes

  • WCSClient
  • WCSCapabilities
  • WCSDescribeCoverage
  • WCSGetCoverage
  • WCSCoverageSummary
  • WCSCoverage
  • WCSCoverageDescription
  • WCSCoverageDomain (for WCS 1.x)
  • WCSCoverageSpatialDomain (for WCS 1.x)
  • WCSCoverageTemporalDomain (for WCS 1.x)
  • WCSCoverageRange

Server implementation Tests

  • Thredds
  • GeoServer
  • Rasdaman

Work funded by EmodNet Biology / VLIZ

CSW Transaction (Update) Failed when Feature Catalogue Citation

When a metadata have a Feature Catalogue Description associated
For example in XML

gmd:contentInfo
gmd:MD_FeatureCatalogueDescription
gmd:includedWithDataset/
<gmd:featureCatalogueCitation xmlns:xlink="http://www.w3.org/1999/xlink"
uuidref="055f393c-17a2-4288-b4df-0c6d33a0d769"
xlink:href="https://portail.indigeo.fr/geonetwork/srv/fre/csw?service=CSW&amp;request=GetRecordById&amp;version=2.0.2&amp;outputSchema=http://www.isotc211.org/2005/gmd&amp;elementSetName=full&amp;id=055f393c-17a2-4288-b4df-0c6d33a0d769"/>
</gmd:MD_FeatureCatalogueDescription>
</gmd:contentInfo>

The CSW updateRecord() method failed with error :

[ows4R][INFO] CSWClient - Transaction (Update) ...
list()
Failed to parse QName ':uuidref'
[geometa][WARN] Element '{http://www.opengis.net/gml}TimePeriod': This element is not expected. Expected is one of ( {http://www.opengis.net/gml/3.2}AbstractTimePrimitive, {http://www.opengis.net/gml/3.2}TimeInstant, {http://www.opengis.net/gml/3.2}TimePeriod, {http://www.opengis.net/gml/3.2}TimeNode, {http://www.opengis.net/gml/3.2}TimeEdge ) at line 366.
[geometa][WARN] Element '{http://www.isotc211.org/2005/gmd}featureCatalogueCitation', attribute ':uuidref': The attribute ':uuidref' is not allowed at line 400.
[geometa][WARN] Object 'ISOMetadata' is INVALID according to ISO 19139 XML schemas!
Failed to parse QName ':uuidref'
Opening and ending tag mismatch: hr line 7 and body
Opening and ending tag mismatch: body line 1 and html
Premature end of data in tag html line 1
Error: 1: Opening and ending tag mismatch: hr line 7 and body
2: Opening and ending tag mismatch: body line 1 and html
3: Premature end of data in tag html line 1

Error while trying to access a WFS 2.0 server

I am trying to access a WFS server with the following piece of script :

require(ows4r) csw <- WFSClient$new("https://services.sentinel-hub.com/ogc/[personal token]", "2.0.0", logger = "INFO")

I get either this error :

list() [ows4R][INFO] OWSGetCapabilities - Fetching https://services.sentinel-hub.com/ogc/wfs/[personal token]?service=WFS&version=2.0.0&request=GetCapabilities Error in if (attr(regexpr(srsPattern, srsName, ignore.case = T), "match.length") > : l'argument est de longueur nulle

or that one :

list() [ows4R][INFO] OWSGetCapabilities - Fetching https://services.sentinel-hub.com/ogc/wfs/[personal token]?service=WFS&version=2.0.0&request=GetCapabilities Error in curl::curl_fetch_memory(url, handle = handle) : Error in the HTTP2 framing layer

When I query the service in my browser, it works fine.

Any idea ?

ows4r version : 0.1-4

`R version 3.5.2 (2018-12-20)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.1 LTS

Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.7.1
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.7.1

locale:
[1] LC_CTYPE=fr_FR.UTF-8 LC_NUMERIC=C LC_TIME=fr_FR.UTF-8 LC_COLLATE=fr_FR.UTF-8 LC_MONETARY=fr_FR.UTF-8 LC_MESSAGES=fr_FR.UTF-8 LC_PAPER=fr_FR.UTF-8
[8] LC_NAME=C LC_ADDRESS=C LC_TELEPHONE=C LC_MEASUREMENT=fr_FR.UTF-8 LC_IDENTIFICATION=C
`

Issue with maxRecords parameter scope in getRecords

maxRecords parameters refers to the number of records per CSW results page in the CSW standard. However, in getRecords(...) operation, maxRecords should apply to the number of records retrieved in total for the getRecords.

Publish metadata on geonode by using CSW-T

I have an error when trying to publish on geonode (pycsw behind the scene) by using CSW-T
ows4R can connect the CSW server but can not insert the XML.
By discussing with the geonode administrator, it looks like there is an issue with the authentication of the user because, when using pycsw with geonode, the authentication for CSW-T is different from the native authentication of pycsw (through IPs).
Not sure if this should be fixed by ows4R or by Geonode.


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

CSW (Catalogue Service for the Web) Client

Classes

  • Constraint - requires implementation of OGC filter encoding #5 (supported in ows4R 0.1)
  • Query - required for GetRecords operation (supported in ows4R 0.1)

Operations
Version 2.0.2

  • GetCapabilities (supported in ows4R 0.1)
  • GetRecordById (supported in ows4R 0.1)
  • GetRecords (supported in ows4R 0.1)
  • DescribeRecord - UNDER INVESTIGATION FOR MAPPING to XMLSchema
  • Transaction
    • Insert (supported in ows4R 0.1)
    • Update (Full) (supported in ows4R 0.1)
    • Update (Partial) - requires an OWS Constraint / OGC Filter (supported in ows4R 0.1)
    • Delete - requires an OWS Constraint / OGC Filter (supported in ows4R 0.1)
  • Harvest (prototype supported in ows4R 0.1)

Version 3.0

  • GetCapabilities (supported in ows4R 0.1)
  • GetRecordById (supported in ows4R 0.1)
  • GetRecords (supported in ows4R 0.1)
  • Transaction (partially supported in ows4R 0.1)
    • Insert (supported in ows4R 0.1)
    • Update (Full) (supported in ows4R 0.1)
    • Update (Partial) - requires an OWS Constraint / OGC Filter
    • Delete - requires an OWS Constraint / OGC Filter
  • Harvest

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

CSW-T inserted metadata do not show WMS/download links in Geonetwork

WMS/download online resources are only show if the user is logged into Geonetwork, despite the CSW-T config for inserted public metadata is enabled. If requested anonymously, the metadata is not showing download and interactive map online resources.

It seems these privileges are not enabled together with "Publish" when metadata is inserted with CSW-T.


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

Features returned from WFS are unexpectedly of geometry type CURVEPOLYGON

Hi,

I am trying to retrieve polygons from a WFS server using the following:

# Connect to WFS
wfs <- WFSClient$new("https://lris.scinfo.org.nz/services;key=[personal token]/wfs",
                     serviceVersion="2.0.0",
                     logger = "INFO")

# Query for polygons within a bounding box
polys <- wfs$getFeatures(typeName = "layer-48076",
                         cql_filter = "bbox(GEOMETRY,5138900,1568632,5172362,1610673)")

This works, but the geometry type of the returned features in my polys object is CURVEPOLYGON, which I did not expect. This is inconvenient because curvepolygons are not fully supported by sf (therefore I can't cast the features to a supported type).

When I test the same query in a web browser, the geometry type of the features in the result is gml:Polygon, so I assumed the geometry type of my polys object would be POLYGON or MULTIPOLYGON.

Are curvepolygons really the correct geometry type in this case, or did I make a mistake somewhere? Am I just misunderstanding something?

Thanks,

Nathan

CSW - Insert Record fails if feature catalogue description has no UUID

When a metadata has a contentInfo/ feature catalogue description, such as generated by geometa (see example of metadata here, the missing uuid attribute on this node induces the following insert error: record parsing failed: 'uuidref'

This is for testing purpose, the issue is more likely to occur in geometa that should provide a way to specify a uuid ref to featureCatalogueDescription node.

SOS (Sensor Observation Service) support

👏 Great job and initiative with this package 👏

Just if you're thinking about adding support for OGC Sensor Observation Service (just sneaking a few keywords in here: Observations & Measurements, SensorML), I'd by happy to have a discussion since there is already a package for that: sos4R: https://cran.r-project.org/package=sos4R

In an ideal world I would rewrite everything to re-use your implementation of the OWS layer (though sos4R is S4), but that's unlikely to happen. There might be some reusable stuff/potential to collaborate in the parsing/conversion of O&M to spacetime data structures?

I'm following your activities here though and wish you best of luck.


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

1st release on CRAN

1st release on CRAN will cover:

  • FES 1.1.0
  • OWS 1.1 possibly 2.0
  • WFS 1.0.0,1.1.1,2.0.0
  • CSW 2.0.2 possibly 3.0

Unexpected curl_fetch_memory error on travis-ci

On Travis-ci: https://travis-ci.org/eblondel/ows4R/jobs/398918995

[ows4R][INFO] OWSGetCapabilities - Fetching http://localhost:8000/csw?service=CSW&version=2.0.2&request=GetCapabilities 
── 1. Error: (unknown) (@test_CSWClient.R#17)  ─────────────���───────────────────
transfer closed with 14431 bytes remaining to read
1: CSWClient$new("http://localhost:8000/csw", "2.0.2", logger = "INFO") at testthat/test_CSWClient.R:17
2: .subset2(public_bind_env, "initialize")(...)
3: CSWCapabilities$new(self$url, self$version, logger = logger)
4: .subset2(public_bind_env, "initialize")(...)
5: super$initialize(url, service = "CSW", serviceVersion = version, owsVersion = owsVersion, 
       logger = logger)
6: OWSGetCapabilities$new(op = NULL, url, service, serviceVersion, logger = logger)
7: .subset2(public_bind_env, "initialize")(...)
8: self$execute()
9: private$GET(private$url, private$request, private$namedParams, private$mimeType)
10: GET(req, add_headers(Expect = ""))
11: request_perform(req, hu$handle$handle)
12: request_fetch(req$output, req$url, handle)
13: request_fetch.write_memory(req$output, req$url, handle)
14: curl::curl_fetch_memory(url, handle = handle)

Installed packages on Travis-ci / R release:

 Rscript -e 'devtools::session_info(installed.packages()[, "Package"])'
Loading ISO 19139 XML schemas...
Loading ISO 19115 codelists...
─ Session info ───────────────────────────────────────────────────────────────
 setting  value                       
 version  R version 3.5.0 (2017-01-27)
 os       Ubuntu 14.04.5 LTS          
 system   x86_64, linux-gnu           
 ui       X11                         
 language (EN)                        
 collate  en_US.UTF-8                 
 tz       UTC                         
 date     2018-07-01                  
─ Packages ───────────────────────────────────────────────────────────────────
 package     * version     date       source                           
 assertthat    0.2.0       2017-04-11 CRAN (R 3.5.0)                   
 backports     1.1.2       2017-12-13 cran (@1.1.2)                    
 base64enc     0.1-3       2015-07-28 cran (@0.1-3)                    
 boot          1.3-20      2017-08-06 CRAN (R 3.5.0)                   
 callr         2.0.4       2018-05-15 cran (@2.0.4)                    
 class         7.3-14      2015-08-30 CRAN (R 3.5.0)                   
 classInt      0.2-3       2018-04-16 CRAN (R 3.5.0)                   
 cli           1.0.0       2017-11-05 CRAN (R 3.5.0)                   
 clipr         0.4.1       2018-06-23 cran (@0.4.1)                    
 clisymbols    1.2.0       2017-05-21 cran (@1.2.0)                    
 cluster       2.0.7-1     2018-04-13 CRAN (R 3.5.0)                   
 codetools     0.2-15      2016-10-05 CRAN (R 3.5.0)                   
 covr          3.1.0       2018-05-18 CRAN (R 3.5.0)                   
 crayon        1.3.4       2017-09-16 CRAN (R 3.5.0)                   
 curl          3.2         2018-03-28 CRAN (R 3.5.0)                   
 DBI           1.0.0       2018-05-02 CRAN (R 3.5.0)                   
 desc          1.2.0       2018-05-01 cran (@1.2.0)                    
 devtools      1.13.5.9000 2018-07-01 Github (hadley/devtools@b01edfb) 
 digest        0.6.15      2018-01-28 CRAN (R 3.5.0)                   
 e1071         1.6-8       2017-02-02 CRAN (R 3.5.0)                   
 enc           0.2.0       2018-03-03 cran (@0.2.0)                    
 evaluate      0.10.1      2017-06-24 cran (@0.10.1)                   
 foreign       0.8-70      2017-11-28 CRAN (R 3.5.0)                   
 geometa       0.3-0       2018-07-01 Github (eblondel/geometa@7073de1)
 gh            1.0.1       2017-07-16 cran (@1.0.1)                    
 git2r         0.22.0.9000 2018-07-01 Github (ropensci/git2r@0862908)  
 glue          1.2.0       2017-10-29 cran (@1.2.0)                    
 highr         0.7         2018-06-09 cran (@0.7)                      
 htmltools     0.3.6       2017-04-28 cran (@0.3.6)                    
 httr          1.3.1       2017-08-20 CRAN (R 3.5.0)                   
 ini           0.3.1       2018-05-20 cran (@0.3.1)                    
 jsonlite      1.5         2017-06-01 CRAN (R 3.5.0)                   
 KernSmooth    2.23-15     2015-06-29 CRAN (R 3.5.0)                   
 knitr         1.20        2018-02-20 cran (@1.20)                     
 lattice       0.20-35     2017-03-25 CRAN (R 3.5.0)                   
 lazyeval      0.2.1       2017-10-29 CRAN (R 3.5.0)                   
 magrittr      1.5         2014-11-22 CRAN (R 3.5.0)                   
 markdown      0.8         2017-04-20 cran (@0.8)                      
 MASS          7.3-50      2018-04-30 CRAN (R 3.5.0)                   
 Matrix        1.2-14      2018-04-13 CRAN (R 3.5.0)                   
 memoise       1.1.0       2017-04-21 CRAN (R 3.5.0)                   
 mgcv          1.8-24      2018-06-18 CRAN (R 3.5.0)                   
 mime          0.5         2016-07-07 CRAN (R 3.5.0)                   
 nlme          3.1-137     2018-04-07 CRAN (R 3.5.0)                   
 nnet          7.3-12      2016-02-02 CRAN (R 3.5.0)                   
 openssl       1.0.1       2018-03-03 CRAN (R 3.5.0)                   
 pillar        1.2.3       2018-05-25 cran (@1.2.3)                    
 pkgbuild      1.0.0       2018-07-01 Github (r-lib/pkgbuild@94d2f0d)  
 pkgload       1.0.0       2018-07-01 Github (r-lib/pkgload@c699550)   
 praise        1.0.0       2015-08-11 CRAN (R 3.5.0)                   
 prettyunits   1.0.2       2015-07-13 cran (@1.0.2)                    
 processx      3.1.0       2018-05-15 cran (@3.1.0)                    
 purrr         0.2.5       2018-05-29 cran (@0.2.5)                    
 R6            2.2.2       2017-06-17 CRAN (R 3.5.0)                   
 rcmdcheck     1.2.1.9005  2018-07-01 Github (r-lib/rcmdcheck@ad42561) 
 Rcpp          0.12.17     2018-05-18 CRAN (R 3.5.0)                   
 rematch2      2.0.1       2017-06-20 cran (@2.0.1)                    
 rex           1.1.2       2017-10-19 CRAN (R 3.5.0)                   
 rgdal         1.3-3       2018-06-22 CRAN (R 3.5.0)                   
 rlang         0.2.1       2018-05-30 CRAN (R 3.5.0)                   
 rmarkdown     1.10        2018-06-11 cran (@1.10)                     
 rpart         4.1-13      2018-02-23 CRAN (R 3.5.0)                   
 rprojroot     1.3-2       2018-01-03 cran (@1.3-2)                    
 rstudioapi    0.7         2017-09-07 CRAN (R 3.5.0)                   
 sessioninfo   1.0.0       2017-06-21 cran (@1.0.0)                    
 sf            0.6-3       2018-05-17 CRAN (R 3.5.0)                   
 sp            1.3-1       2018-06-05 CRAN (R 3.5.0)                   
 spatial       7.3-11      2015-08-30 CRAN (R 3.5.0)                   
 spData        0.2.9.0     2018-06-17 CRAN (R 3.5.0)                   
 stringi       1.2.3       2018-06-12 cran (@1.2.3)                    
 stringr       1.3.1       2018-05-10 cran (@1.3.1)                    
 styler        1.0.2       2018-06-26 cran (@1.0.2)                    
 survival      2.42-4      2018-06-30 CRAN (R 3.5.0)                   
 testthat      2.0.0       2017-12-13 CRAN (R 3.5.0)                   
 tibble        1.4.2       2018-01-22 cran (@1.4.2)                    
 tinytex       0.5         2018-04-16 cran (@0.5)                      
 units         0.6-0       2018-06-09 CRAN (R 3.5.0)                   
 usethis       1.3.0       2018-02-24 cran (@1.3.0)                    
 utf8          1.1.4       2018-05-24 cran (@1.1.4)                    
 whisker       0.3-2       2013-04-28 CRAN (R 3.5.0)                   
 withr         2.1.2       2018-03-15 CRAN (R 3.5.0)                   
 XML           3.98-1.11   2018-06-11 CRAN (R 3.5.0)                   
 yaml          2.1.19      2018-05-01 cran (@2.1.19)                  

On local machine, no problem:

[ows4R][INFO] OWSGetCapabilities - Fetching http://localhost:8000/csw?service=CSW&version=2.0.2&request=GetCapabilities 
-> GET /csw?service=CSW&version=2.0.2&request=GetCapabilities HTTP/1.1
-> Host: localhost:8000
-> User-Agent: libcurl/7.56.1 r-curl/3.1 httr/1.3.1
-> Accept-Encoding: gzip, deflate
-> Accept: application/json, text/xml, application/xml, */*
-> 
<- HTTP/1.1 200 OK
<- Server: gunicorn/19.7.1
<- Date: Sun, 01 Jul 2018 22:47:17 GMT
<- Connection: close
<- Content-Length: 17709
<- Content-Type: application/xml; charset=UTF-8
<- 

error returned by wfs$getFeatures

I can't share data or geoserver address, but basically everything seems to work up to the query for the simple feature:
wfs = WFSClient$new(url=", serviceVersion="2.0.0",
user="admin", pwd="geoserver")
wfs$getCapabilities()
wfs$getFeatureTypes(T)

get capabilities

caps <- wfs$getCapabilities()

find feature type

ft <- caps$findFeatureTypeByName("name1:name2", exact = TRUE)

both of these return same message

sf1 = ft$getFeatures("name1:name2", cql_filter="cell_id='608524524752732159'")
sf1 = wfs$getFeatures("name1:name2", cql_filter="cell_id='609094538316742655'")

Error in CPL_read_ogr(dsn, layer, query, as.character(options), quiet, :
NULL error in sfc_from_ogr

WFS problems with geometry column and text conversion

Hi Emmanuel,
first, thank you again for developing OGC web services for R! I have played around a bit with your package, and stumbled across two potential bugs.

  1. When loading data into R, you seem to look for a geometry column (or tag), however, sometimes the column (tag) containing the geometry is unfortunately not named geometry, as is the case with this Dutch example where it is called "geometrie". The solution might be to use sf to read the downloaded GML file into R (see below, and FYI @Robinlovelace and @Nowosad):
library(ows4R)
#> Loading required package: geometa
#> Loading ISO 19139 XML schemas...
#> Loading ISO 19115 codelists...
library(sf)
#> Linking to GEOS 3.6.2, GDAL 2.3.2, proj.4 5.1.0
base_url = "http://geodata.nationaalgeoregister.nl/bag/wfs"
wfs = WFSClient$new(base_url, "1.0.0", logger = "INFO")
#> [ows4R][INFO] OWSGetCapabilities - Fetching http://geodata.nationaalgeoregister.nl/bag/wfs?service=WFS&version=1.0.0&request=GetCapabilities
caps = wfs$getCapabilities()
tmp = caps$findFeatureTypeByName("")
# find out about the available feature types
sapply(tmp, function(x) x$getName())
#> [1] "bag:ligplaats"       "bag:pand"            "bag:standplaats"    
#> [4] "bag:verblijfsobject" "bag:woonplaats"
# ok, let's download the national parcs of Bavaria
# ft = caps$findFeatureTypeByName("lfu:nationalpark")
ft = caps$findFeatureTypeByName("bag:ligplaats")
# download features
feats = ft$getFeatures()  
#> [ows4R][INFO] WFSGetFeature - Fetching http://geodata.nationaalgeoregister.nl/bag/wfs?service=WFS&version=1.0.0&typeName=bag:ligplaats&logger=INFO&request=GetFeature 
#> [ows4R][INFO] WFSDescribeFeatureType - Fetching http://geodata.nationaalgeoregister.nl/bag/wfs?service=WFS&version=1.0.0&typeName=bag:ligplaats&request=DescribeFeatureType
#> Error in if (element$getType() == "geometry") {: argument is of length zero
# obviously getFeatures() is looking for a geometry column, however, here it
# is named "geometrie", that's why it doesn't work this does not work
# However, it downloads the gml file to the temporary directory, hence,
# we can load the data into R ourselves
file = grep("gml", dir(tempdir()), value = TRUE)
file = file.path(tempdir(), file)
# assuming there is only one file
layer = read_sf(file)
plot(layer$geometrie)

Created on 2018-10-19 by the reprex package (v0.2.1)

  1. I also tried a German WFS. Here, it seems, there is some problem when using switch():
library(ows4R)
#> Loading required package: geometa
#> Loading ISO 19139 XML schemas...
#> Loading ISO 19115 codelists...
library(sf)
#> Linking to GEOS 3.6.2, GDAL 2.3.2, proj.4 5.1.0
base_url = "http://www.lfu.bayern.de/gdi/wfs/naturschutz/schutzgebiete?"
wfs = WFSClient$new(base_url, "1.0.0", logger = "INFO")
#> [ows4R][INFO] OWSGetCapabilities - Fetching http://www.lfu.bayern.de/gdi/wfs/naturschutz/schutzgebiete?service=WFS&version=1.0.0&request=GetCapabilities
caps = wfs$getCapabilities()
tmp = caps$findFeatureTypeByName("")
# find out about the available feature types
sapply(tmp, function(x) x$getName())
#> [1] "lfu:vogelschutzgebiet"          "lfu:naturpark"                 
#> [3] "lfu:naturschutzgebiet"          "lfu:landschaftsschutzgebiet"   
#> [5] "lfu:fauna_flora_habitat_gebiet" "lfu:biosphaerenreservat"       
#> [7] "lfu:nationalpark"
ft = caps$findFeatureTypeByName("lfu:nationalpark")
feats = ft$getFeatures()  
#> [ows4R][INFO] WFSGetFeature - Fetching http://www.lfu.bayern.de/gdi/wfs/naturschutz/schutzgebiete?service=WFS&version=1.0.0&typeName=lfu:nationalpark&logger=INFO&request=GetFeature 
#> [ows4R][INFO] WFSDescribeFeatureType - Fetching http://www.lfu.bayern.de/gdi/wfs/naturschutz/schutzgebiete?service=WFS&version=1.0.0&typeName=lfu:nationalpark&request=DescribeFeatureType
#> Error in switch(type, `xsd:string` = "character", `xsd:long` = "numeric", : EXPR must be a length 1 vector
# here, there seems to be a conversion error...
# still, we can load the data into R ourselves
file = grep("gml", dir(tempdir()), value = TRUE)
file = file.path(tempdir(), file)
layer = read_sf(file)
#> Warning in CPL_read_ogr(dsn, layer, as.character(options), quiet, type, :
#> GDAL Error 1: HTTP error code : 404
plot(layer$geometry)

Created on 2018-10-19 by the reprex package (v0.2.1)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.