1

I'm trying to determine the version number of several WFS using the python module owslib. since i need to use this version number in ogr2ogr (and for some reason, python's ogr2ogr only works in Qgis' editor), i am runnign this in Qgis 3.2's python editor window.

This has been working fine for around 5-6 wfs urls (both with http and https). however when i get to the url: https://arealinformation.miljoeportal.dk/gis/services/DAIdb/MapServer/WFSServer?service=WFS

the code:

from owslib.wfs import WebFeatureService as wfsmod
url = "https://arealinformation.miljoeportal.dk/gis/services/DAIdb/MapServer/WFSServer?service=WFS"
wfs = wfsmod(url)

crashes and returns:

requests.exceptions.HTTPError: 500 Server Error: Internal Server Error for url: https://arealinformation.miljoeportal.dk/gis/services/DAIdb/MapServer/WFSServer?service=WFS%C2%A0+&request=GetCapabilities&version=1.0.0

I have tried the code both in the python console in qgis 3.2 and in a seperate python IDE. It works there without crashing. But as said, i need to run this in the editor because this snippet is part of a larger code, which doesn't function in the IDE and the python console window in qgis.

  • To determine the highest supported version of any OGC interface standard (WMS/WFS/WCS..) send a GetCapabilities request without version, for you like: https://arealinformation.miljoeportal.dk/gis/services/DAIdb/MapServer/WFSServer?service=WFS&request=GetCapabilities. – nmtoken Jan 13 at 8:39
  • The base URL you use should be the URL for the service without any request parameters so for you just https://arealinformation.miljoeportal.dk/gis/services/DAIdb/MapServer/WFSServer? – nmtoken Jan 13 at 8:41
1

You'll probably need some code like:

from owslib.wfs import WebFeatureService as wfsmod

url = "https://arealinformation.miljoeportal.dk/gis/services/DAIdb/MapServer/WFSServer?"
try:
    wfs = wfsmod(url, version='2.0.0')
except ExplicitException:
    try:
         wfs = wfsmod(url, version='1.1.0')
    except ExplicitException:
        try:
            wfs = wfsmod(url, version='1.0.0')
        except ExplicitException:
            pass
finally:
    # do something
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.