OWSLib
OWSLib copied to clipboard
WFS service: get_schema fails if <complexType> has no attribute "name"
Some WFS servers to not define a name
attribute in the <complexType>
tag. in the response of DescribeFeatureType
. In addition, the <element>
has no type
attribute then.
Example URLs:
- https://geodienste.hamburg.de/HH_WFS_Sportstaetten
- https://geodienste.hamburg.de/HH_WFS_Verkehr_opendata
These services provided by a Deegree WFS server.
Code to test an reproduce:
import requests
from owslib.wfs import WebFeatureService
version = '2.0.0'
url = "https://geodienste.hamburg.de/HH_WFS_Sportstaetten"
wfs = WebFeatureService(url=url, version=version)
# Get all available layers
layers = list(wfs.contents)
# print the response of `DescribeFeatureType`
layer=layers[0]
params=dict(service='WFS', version=version, request='DescribeFeatureType',
typeName=layer)
r = requests.get(url, params=params)
print(r.text)
xml_str = r.text
Retrieving the schema fails:
wfs.get_schema(layer)
Traceback (most recent call last):
Input In [6] in <cell line: 1>
wfs.get_schema(layer)
File C:\miniconda3\envs\py38\lib\site-packages\owslib\feature\__init__.py:380 in get_schema
return get_schema(self.url, typename, self.version, auth=self.auth)
File C:\miniconda3\envs\py38\lib\site-packages\owslib\feature\schema.py:57 in get_schema
complex_type = type_element.attrib["type"].split(":")[1]
File src/lxml/etree.pyx:2494 in lxml.etree._Attrib.__getitem__
KeyError: 'type'