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

Error while trying to access a WFS 2.0 server

ptaconet opened this issue · comments

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
`

@ptaconet I've pushed some fixs, the 1st is the one for which you got an error, I've handled better support for WFS 2.0 which is not well handled (because not tested deeply so far). I've also added some control to deal with badly handled primitive types in describeFeatureType. In theory I should not do that because this is likely to be a problem on server side, where the DescribeFeatureType response is not handled well. I encourage you to report this to the service provider.

Finally, i tried to get features, but it doesn't work, here as well it's to a problem of WFS compliance since the base GetFeature request https://services.sentinel-hub.com/ogc/wfs/[personal token]?service=WFS&version=2.0.0&typeNames=DSS3&request=GetFeature should work, but it doesn't. It asks for bbox or geometry fields. If you try to give bbox param, it returns zero features.
On this aspect as well, I encourage to get in touch with the service provider, as I can't do anything on ows4R to deal with this issue.

@ptaconet it would be good also to know which implementation they use for their OGC WFS. If it is a known product (geoserver, mapserver, esri, etc), or if they did their own implementation of WFS

I provide below the answer from the service provider (sentinel-hub) (for some reason they were not able to answer directly in the forum) :

Hi @eblondel ,
Sentinel Hub's WFS service is based on own (proprietary) implementation.
I am not familiar with ows4R package so I cannot help much, but some notes if they help:

-WFS has some constraints implemented to prevent unnecessary load to the index database (as there are tens of millions of records inside a loose query might cause problems). Therefore, if one does not add BBOX or BBOX is too large, these constraints will kick in and no results will be retreived. So if possible, do use some default, small, BBOX (e.g. srsname=EPSG:3857&bbox=-448167,4908150,-382278,494033)

-unless TIME parameter is added, the query will default to last one month of data - you should still receive results, but note that these are not all will get through.

Ok, i see so what you need to do with ows4R is to specify both srsName and bbox params (although please note that adding them should not be mandatory in the WFS spec, at least it should be documented properly in the featureType description, especially the srsName, which is not done in this server).

Knowing these server constraints, you can add these parameters to the getFeatures method:

#connect to wfs
wfs <- WFSClient$new("https://services.sentinel-hub.com/ogc/wfs/[your token]", "2.0.0", logger = "INFO") 
#get feature type
ft <- wfs$capabilities$findFeatureTypeByName("DSS3")
#get data
sf <- ft$getFeatures(srsName = "EPSG:3857", bbox="-448167,4908150,-382278,494033")

You can also directly getFeatures from the WFS client if more convenient for you:

sf <- wfs$getFeatures("DSS3", srsName = "EPSG:3857", bbox="-448167,4908150,-382278,494033")

Let me know, but in principle this should do what you want

Thanks, your workaround worked for me ! :)