83
83
---
84
84
Connect to a WFS and inspect its capabilities.
85
85
86
- ::
86
+ .. code-block :: python
87
87
88
88
>> > from owslib.wfs import WebFeatureService
89
- >>> wfs11 = WebFeatureService(url='http ://geoserv.weichand.de:8080/geoserver /wfs', version='1.1 .0')
90
- >>> wfs11 .identification.title
91
- 'INSPIRE WFS 2.0 DemoServer Verwaltungsgrenzen Bayern
89
+ >> > wfs20 = WebFeatureService(url = ' https ://services.rce.geovoorziening.nl/dijken /wfs' , version = ' 2.0 .0' )
90
+ >> > wfs20 .identification.title
91
+ ' Landschapsatlas '
92
92
93
- >>> [operation.name for operation in wfs11.operations]
94
- ['GetCapabilities', 'DescribeFeatureType', 'GetFeature', 'GetGmlObject']
93
+ >> > [operation.name for operation in wfs20.operations]
94
+ [' GetCapabilities' , ' DescribeFeatureType' , ' GetFeature' , ' GetPropertyValue' , ' ListStoredQueries' , ' DescribeStoredQueries' ,
95
+ ' CreateStoredQuery' , ' DropStoredQuery' , ' ImplementsBasicWFS' , ' ImplementsTransactionalWFS' , ' ImplementsLockingWFS' ,
96
+ ' KVPEncoding' , ' XMLEncoding' , ' SOAPEncoding' , ' ImplementsInheritance' , ' ImplementsRemoteResolve' , ' ImplementsResultPaging' ,
97
+ ' ImplementsStandardJoins' , ' ImplementsSpatialJoins' , ' ImplementsTemporalJoins' , ' ImplementsFeatureVersioning' ,
98
+ ' ManageStoredQueries' , ' PagingIsTransactionSafe' , ' QueryExpressions' ]
95
99
96
100
List FeatureTypes
97
101
98
- ::
102
+ .. code-block :: python
99
103
100
- >>> list(wfs11 .contents)
101
- ['bvv:vg_ex ', 'bvv:bayern_ex', 'bvv:lkr_ex', 'bvv:regbez_ex', 'bvv:gmd_ex ']
104
+ >> > list (wfs20 .contents)
105
+ [' dijken:dijken_bovenregionale_betekenis ' , ' dijken:dijklijnenkaart_rce ' ]
102
106
103
107
Download GML using ``typename ``, ``bbox `` and ``srsname ``.
104
108
105
- ::
109
+ .. code-block :: python
106
110
107
111
>> > # OWSLib will switch the axis order from EN to NE automatically if designated by EPSG-Registry
108
- >>> response = wfs11.getfeature(typename='bvv:gmd_ex', bbox=(4500000,5500000,4500500,5500500), srsname='urn:x-ogc:def:crs:EPSG:31468')
112
+ >> > response = wfs20.getfeature(typename = ' dijken:dijklijnenkaart_rce' , bbox = (173700 ,440400 ,178700 ,441400 ), srsname = ' EPSG:28992' )
113
+ >> > str (response.read())
114
+ ' b\' <?xml version="1.0" encoding="UTF-8"?><dijken:dijklijnenkaart_rce...\' '
115
+
116
+ Download in other formats (if supported by server) and pagination.
117
+
118
+ .. code-block :: python
119
+
120
+ >> > # Check which output formats are available for GetFeature
121
+ >> > [o.parameters[' outputFormat' ][' values' ] for o in wfs20.operations if o.name== ' GetFeature' ]
122
+ [[' application/gml+xml; version=3.2' , ' DXF' , ' DXF-ZIP' , ' GML2' , ' KML' , ' SHAPE-ZIP' , ' application/json' , ' application/vnd.google-earth.kml xml' ,
123
+ ' application/vnd.google-earth.kml+xml' , ' csv' , ' gml3' , ' gml32' , ' json' , ' text/csv' , ' text/xml; subtype=gml/2.1.2' , ' text/xml; subtype=gml/3.1.1' , ' text/xml; subtype=gml/3.2' ]]
124
+ >> > response = wfs20.getfeature(typename = ' dijken:dijklijnenkaart_rce' , bbox = (173700 ,440400 ,178700 ,441400 ), srsname = ' EPSG:28992' , outputFormat = ' application/json' )
125
+ >> > response.read()
126
+ b ' {"type":"FeatureCollection","features":...'
127
+ >> > response = wfs20.getfeature(typename = ' dijken:dijklijnenkaart_rce' , srsname = ' EPSG:4326' , maxfeatures = 20 , startindex = 1 )
128
+ ' b\' <?xml version="1.0" encoding="UTF-8"?><dijken:dijklijnenkaart_rce...\' '
109
129
110
130
Return a FeatureType's schema via ``DescribeFeatureType ``. The dictionary returned is
111
131
compatible with a `Fiona schema object <https://fiona.readthedocs.io/en/latest/fiona.html#fiona.collection.Collection.schema >`_.
112
132
113
- ::
133
+ .. code-block :: python
134
+
135
+ >> > wfs20.get_schema(' dijken:dijklijnenkaart_rce' )
136
+ {' properties' : {' ogc_fid' : ' int' , ' id' : ' string' , ' naam' : ' string' , ' aanleg_beg' : ' string' , ' aanleg_ein' : ' string' , ' aanleg_ind' : ' string' , ' status' : ' string' , ' herkomst' : ' string' , ' verdwenen' : ' string' , ' oorsprfunc' : ' string' , ' naspfunc' : ' string' , ' bijzonderh' : ' string' , ' bron_data' : ' string' , ' bron_id' : ' string' , ' bron_geo' : ' string' , ' rce_zone' : ' string' , ' waternaam' : ' string' , ' polder' : ' string' , ' shape_leng' : ' double' , ' opmerking' : ' string' , ' laatst_bew' : ' date' }, ' required' : [' ogc_fid' ], ' geometry' : ' GeometryCollection' , ' geometry_column' : ' wkb_geometry' }
114
137
115
- >>> wfs11.get_schema('bvv:vg_ex')
116
- >>> {'properties': {'land': 'string', 'modellart': 'string', 'objart': 'string', 'objart_txt': 'string', 'objid': 'string', 'hdu_x': 'short', 'beginn': 'string', 'ende': 'string', 'adm': 'string', 'avg': 'string', 'bez_gem': 'string', 'bez_krs': 'string', 'bez_lan': 'string', 'bez_rbz': 'string', 'sch': 'string'}, 'geometry': '3D MultiPolygon', 'geometry_column': 'geom'}
117
138
118
139
Download GML using ``typename `` and ``filter ``.
119
140
120
141
Usage with WFS 1.1 (FE.1.1):
121
142
122
- ::
143
+ .. code-block :: python
123
144
124
145
>> > from owslib.fes import *
125
146
>> > from owslib.etree import etree
126
147
>> > from owslib.wfs import WebFeatureService
127
- >>> wfs11 = WebFeatureService(url='http ://geoserv.weichand.de:8080/geoserver /wfs', version='1.1.0')
148
+ >> > wfs10 = WebFeatureService(url = ' https ://services.rce.geovoorziening.nl/dijken /wfs' , version = ' 1.1.0' )
128
149
129
- >>> filter = PropertyIsLike(propertyname='bez_gem ', literal='Ingolstadt ', wildCard='*')
150
+ >> > filter = PropertyIsLike(propertyname = ' naam ' , literal = ' Haarlemmer* ' , wildCard = ' *' )
130
151
>> > filterxml = etree.tostring(filter .toXML()).decode(" utf-8" )
131
- >>> response = wfs11 .getfeature(typename='bvv:gmd_ex ', filter=filterxml)
152
+ >> > response = wfs10 .getfeature(typename = ' dijken:dijklijnenkaart_rce ' , filter = filterxml)
132
153
133
154
Usage with WFS 2.0 (FE.2.0):
134
155
@@ -147,7 +168,7 @@ Usage with WFS 2.0 (FE.2.0):
147
168
148
169
Save response to a file.
149
170
150
- ::
171
+ .. code-block :: python
151
172
152
173
>> > out = open (' /tmp/data.gml' , ' wb' )
153
174
>> > out.write(bytes (response.read(), ' UTF-8' ))
@@ -156,21 +177,22 @@ Save response to a file.
156
177
Download GML using ``StoredQueries ``\ (only available for WFS 2.0
157
178
services)
158
179
159
- ::
180
+ .. code-block :: python
160
181
161
182
>> > from owslib.wfs import WebFeatureService
162
- >>> wfs20 = WebFeatureService(url='http ://geoserv.weichand.de:8080/geoserver /wfs', version='2.0.0')
183
+ >> > wfs20 = WebFeatureService(url = ' https ://services.rce.geovoorziening.nl/dijken /wfs' , version = ' 2.0.0' )
163
184
164
185
>> > # List StoredQueries
165
186
>> > [storedquery.id for storedquery in wfs20.storedqueries]
166
- ['bboxQuery', ' urn:ogc:def:query:OGC-WFS::GetFeatureById', 'GemeindeByGemeindeschluesselEpsg31468', 'DWithinQuery ']
187
+ [' urn:ogc:def:query:OGC-WFS::GetFeatureById' ]
167
188
168
- >>> # List Parameters for StoredQuery[1 ]
169
- >>> parameter.name for parameter in wfs20.storedqueries[1 ].parameters]
189
+ >> > # List Parameters for StoredQuery[0 ]
190
+ >> > [ parameter.name for parameter in wfs20.storedqueries[0 ].parameters]
170
191
[' ID' ]
171
192
172
-
173
- >>> response = wfs20.getfeature(storedQueryID='urn:ogc:def:query:OGC-WFS::GetFeatureById', storedQueryParams={'ID':'gmd_ex.1'})
193
+ >> > response = wfs20.getfeature(storedQueryID = ' urn:ogc:def:query:OGC-WFS::GetFeatureById' , storedQueryParams = {' ID' :' dijklijnenkaart_rce.13364' })
194
+ >> > str (response.read())
195
+ ' b\' <?xml version="1.0" encoding="UTF-8"?><dijken:dijklijnenkaart_rce...\' '
174
196
175
197
OGC API
176
198
-------
0 commit comments