6

I want to execute DescribeFeatureType operation of WFS services. However, I can’t find the method to fulfil this operation in OWSLib. Can anyone kind enough to tell me how to do this?

The following is my code snippet:

from owslib.wms import  WebMapService
from owslib.wfs import  WebFeatureService as wfsServericelayer

wfslayer=wfsServericelayer('http://***:8080/geoserver/test/ows')
for i in wfslayer.operations:
    print i.name

Gives:

GetCapabilities
DescribeFeatureType
GetFeature

But how to execute the DescribeFeatureType method?

operationT=wfslayer.getOperationByName('DescribeFeatureType')
3
  • Is it that you can't find the DescribeFeatureType method or that you don't know how to execute or call the method?
    – papadoo
    Commented Aug 4, 2014 at 16:43
  • hi @papadoo i can't find the DescribeFeatureType method in the owslib libariry
    – Suwen
    Commented Aug 5, 2014 at 0:58
  • Have you tried using the IWebFeatureService? Here is a link to the source code which has the describefeaturetype method -- github.com/geopython/OWSLib/blob/…
    – papadoo
    Commented Aug 5, 2014 at 13:50

1 Answer 1

4

This question is a little old but is still first on Google, so for anyone else coming across it.

The properties from the DescribeFeatureType operation can be retrieved using the WebFeatureService.get_schema method.

For example, for the following XML returned from the DescribeFeatureType operation;

<xsd:schema xmlns:test="/" xmlns:gml="http://www.opengis.net/gml" xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="/">
    <xsd:import namespace="http://www.opengis.net/gml" schemaLocation="http://geoserver:8080/geoserver/schemas/gml/2.1.2/feature.xsd"/>
    <xsd:complexType name="change_points_latestType">
        <xsd:complexContent>
            <xsd:extension base="gml:AbstractFeatureType">
                <xsd:sequence>
                    <xsd:element maxOccurs="1" minOccurs="0" name="start" nillable="true" type="xsd:string"/>
                    <xsd:element maxOccurs="1" minOccurs="0" name="end" nillable="true" type="xsd:string"/>
                    <xsd:element maxOccurs="1" minOccurs="0" name="source" nillable="true" type="xsd:string"/>
                    <xsd:element maxOccurs="1" minOccurs="0" name="area_ha" nillable="true" type="xsd:decimal"/>
                    <xsd:element maxOccurs="1" minOccurs="0" name="class" nillable="true" type="xsd:string"/>
                    <xsd:element maxOccurs="1" minOccurs="0" name="quality" nillable="true" type="xsd:string"/>
                    <xsd:element maxOccurs="1" minOccurs="0" name="coord_x" nillable="true" type="xsd:decimal"/>
                    <xsd:element maxOccurs="1" minOccurs="0" name="coord_y" nillable="true" type="xsd:decimal"/>
                    <xsd:element maxOccurs="1" minOccurs="0" name="id" nillable="true" type="xsd:decimal"/>
                    <xsd:element maxOccurs="1" minOccurs="0" name="geom" nillable="true" type="gml:PointPropertyType"/>
                </xsd:sequence>
            </xsd:extension>
        </xsd:complexContent>
    </xsd:complexType>
    <xsd:element name="change_points_latest" substitutionGroup="gml:_Feature" type="test:change_points_latestType"/>
</xsd:schema>

The properties can be retrieved;

 service = WebFeatureService(url, version='1.0.0')
 service.get_schema('change_points_latest')

This will output:

{'geometry': 'Point', 'properties': {'area_ha': 'decimal', 'class': 'string', 'start': 'string', 'id': 'decimal', 'source': 'string', 'coord_y': 'decimal', 'end': 'string', 'coord_x': 'decimal', 'quality': 'string'}}

Ref: WebFeatureService_.get_schema source - https://github.com/geopython/OWSLib/blob/HEAD/owslib/feature/init.py#L166

Your Answer

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

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