20 Working with Web Feature Services
Contents
20 Working with Web Feature Services#
In computing, the Open Geospatial Consortium Web Feature Service (WFS) Interface Standard provides an interface allowing requests for geographical features across the web using platform-independent calls. One can think of geographical features as the “source code” behind a map, whereas the WMS interface or online tiled mapping portals like Google Maps return only an image, which end-users cannot edit or spatially analyze. The XML-based GML furnishes the default payload-encoding for transporting geographic features, but other formats like shapefiles can also serve for transport.
Source: https://en.wikipedia.org/wiki/Web_Feature_Service
Set File Paths and download Tutorial Data#
If you downloaded the latest GemGIS
version from the Github repository, append the path so that the package can be imported successfully. Otherwise, it is recommended to install GemGIS
via pip install gemgis
and import GemGIS
using import gemgis as gg
. In addition, the file path to the folder where the data is being stored is set. The tutorial data is downloaded using Pooch (https://www.fatiando.org/pooch/latest/index.html) and stored in the specified folder. Use
pip install pooch
if Pooch is not installed on your system yet.
[1]:
import gemgis as gg
file_path ='data/20_working_with_web_feature_services/'
WARNING (theano.configdefaults): g++ not available, if using conda: `conda install m2w64-toolchain`
C:\Users\ale93371\Anaconda3\envs\test_gempy\lib\site-packages\theano\configdefaults.py:560: UserWarning: DeprecationWarning: there is no c++ compiler.This is deprecated and with Theano 0.11 a c++ compiler will be mandatory
warnings.warn("DeprecationWarning: there is no c++ compiler."
WARNING (theano.configdefaults): g++ not detected ! Theano will be unable to execute optimized C-implementations (for both CPU and GPU) and will default to Python implementations. Performance will be severely degraded. To remove this warning, set Theano flags cxx to an empty string.
WARNING (theano.tensor.blas): Using NumPy C-API based implementation for BLAS functions.
Loading the WFS Service#
For this example, we are downloading a WFS Service provided by the Landesamt für Bergbau, Energie und Geologie - Niedersachsen. It contains Polygon, Line and Point data about seismic surveys and wells in Northern Germany.
[3]:
wfs = gg.web.load_wfs("https://nibis.lbeg.de/net3/public/ogc.ashx?NodeId=476&Service=WFS&")
wfs
[3]:
<owslib.feature.wfs100.WebFeatureService_1_0_0 at 0x19260e21340>
[3]:
type(wfs)
[3]:
owslib.feature.wfs100.WebFeatureService_1_0_0
Checking the version of the WFS#
[4]:
wfs.version
[4]:
'1.0.0'
Checking the version of the WFS#
[5]:
wfs.identification.version
[5]:
'1.0.0'
Checking the identification type of the WFS#
[6]:
wfs.identification.type
[6]:
'Geophysik und Tiefohrungen'
Checking the title of the WFS#
[7]:
wfs.identification.title
[7]:
'Geophysik und Tiefohrungen'
Checking the abstract of the WFS#
[8]:
wfs.identification.abstract
[8]:
'Geophysik und Tiefohrungen'
Checking the contents of the WFS#
[9]:
list(wfs.contents)
[9]:
['iwan:L383']
Checking the title of the WFS layer#
[10]:
wfs['iwan:L383'].title
[10]:
'Gravimetrie'
Checking the bounding box of the WFS layer#
[11]:
wfs['iwan:L383'].boundingBoxWGS84
[11]:
(5.395175801132899, 47.16510247399335, 17.002272548448747, 54.85398076006902)
Checking the operations for the WFS#
[12]:
[op.name for op in wfs.operations]
[12]:
['GetCapabilities', 'DescribeFeatureType', 'GetFeature']
Checking the format for getting the feature#
[13]:
wfs.getOperationByName('GetFeature').formatOptions
[13]:
['{http://www.opengis.net/wfs}GML2']
Checking the format for describing the feature#
[14]:
wfs.getOperationByName('DescribeFeatureType').formatOptions
[14]:
[]
Checking the format for getting the capabilities#
[15]:
wfs.getOperationByName('GetCapabilities').formatOptions
[15]:
[]
Requesting data from the WFS#
The features can be loaded with the function load_as_gpd(..)
.
[16]:
feature = gg.web.load_as_gpd("https://nibis.lbeg.de/net3/public/ogc.ashx?NodeId=476&Service=WFS&")
Checking the head of the data#
[17]:
feature.head()
[17]:
gml_id | OBJECTID | ID | SURVEYNAME | ARCHIV | MESSJAHR | OPERATOR | OP_NACHFOL | MESSFIRMA | MESSPUNKTE | UP_DATE | geometry | |
---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | 1541 | 1541 | 112 | Jemgum 2007 | 0127494 | 2007 | GdF Produktion Exploration Deutschland GmbH | Neptune Energy Deutschland GmbH | Geophysik und Geotechnik Leipzig GmbH | 1340 | 2020-01-20T00:00:00+01:00 | MULTIPOLYGON (((32395246.839 5907777.660, 3239... |
1 | 1542 | 1542 | 111 | Sagermeer 2005 | 0125831 | 2005 | ExxonMobil Production Deutschland GmbH | ExxonMobil Production Deutschland GmbH | Comp. Generale Geophysique | 2803 | 2020-01-20T00:00:00+01:00 | MULTIPOLYGON (((32446717.522 5856710.088, 3244... |
2 | 1543 | 1543 | 120 | Hümmling 2013 | 0131520 | 2013 | GDF SUEZ E&P DEUTSCHLAND GMBH | Neptune Energy Deutschland GmbH | Deutsche Montan Technologie GmbH | 342 | 2020-01-20T00:00:00+01:00 | MULTIPOLYGON (((32416592.825 5852885.544, 3241... |
3 | 1544 | 1544 | 49 | Rotenburg/Wümme (1984) | 0112162 | 1984 | Deutsche Texaco AG Aufschluss und Gew. | Wintershall Dea Deutschland AG | Prakla Seismos | 2184 | 2020-01-20T00:00:00+01:00 | POLYGON ((32545955.921 5896473.525, 32544536.2... |
4 | 1545 | 1545 | 102 | Odisheim 1989/90 | 0112092 | 1989 | BEB Erdgas und Erdöl GmbH | BEB Erdgas und Erdöl GmbH & Co. KG | Prakla Seismos | 2824 | 2020-01-20T00:00:00+01:00 | POLYGON ((32504255.640 5967591.298, 32503387.8... |
Plotting the data#
[18]:
import matplotlib.pyplot as plt
feature.plot()
plt.grid()