5

I'm trying to access the Sentinel Hub's WFS via PyQGIS. Here's my code:

base_url = 'https://services.sentinel-hub.com/ogc/wfs/<my_service_endpoint>?'
params = 'SRSNAME=EPSG:4326&TYPENAMES=DSS2&GEOMETRY=<some wkt polygon>'
layer = QgsVectorLayer(base_url + params, 'layername', 'wfs')
QgsProject.instance().addMapLayer(layer)

The resulting layer is valid but the requests fail with code 400 because PyQGIS converts EPSG:4326 to urn:ogc:def:crs:EPSG::4326 (OGC URN) as can be seen in the debugger window below:

enter image description here

The reason is, the Sentinel Hub WFS server doesn't understand OGC URNs, and expects a simple EPSG identifier e.g. ESPG:4326. Is there a way to prevent PyQGIS from performing this conversion?

Stack
QGIS version 3.22.1-Białowieża
QGIS code revision 663dcf8fb9
Qt version 5.12.8
Python version 3.8.10
GDAL/OGR version 3.0.4
PROJ version 6.3.1
EPSG Registry database version v9.8.6 (2020-01-22)
OS version Ubuntu 20.04.3 LTS

7
  • Similar topic: gis.stackexchange.com/questions/338082/…
    – Taras
    Commented Dec 14, 2021 at 11:12
  • Thanks, I've seen that one. But that answer doesn't solve this specific problem. Commented Dec 14, 2021 at 13:11
  • What CRS identifiers are returned by the version 2.0.0 GetCapabilities response for the service?
    – nmtoken
    Commented Jan 11, 2022 at 10:42
  • srsname is optional so what if you don't supply it? I also note that the coordinates in the geometry polygon, are not epsg::4326 coordinates, if they were they would have values of no greater than +/-180, so possibly you have some other issue
    – nmtoken
    Commented Jan 11, 2022 at 10:56
  • 2
    Note that according to the WFS 2.0.0 standard a server must support urns ~ Servers that implement this International Standard shall be able to process srsName attribute values using the following format model: urn:ogc:def:objectType:authority:version:<EPSG code> (see OGC 07-092r2)
    – nmtoken
    Commented Jan 12, 2022 at 10:28

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.