In [1]:
%matplotlib inline
import os, sys
import inspect
In [3]:
import pydov
In [4]:
from pydov.search.interpretaties import HydrogeologischeStratigrafieSearch
ip_hydrogeo = HydrogeologischeStratigrafieSearch()
# information about the HydrogeologischeStratigrafie type (In Dutch):
print(ip_hydrogeo.get_description())
In [5]:
# information about the available fields for a HydrogeologischeStratigrafie object
fields = ip_hydrogeo.get_fields()
# print available fields
for f in fields.values():
print(f['name'])
In [6]:
# print information for a certain field
fields['aquifer']
Out[6]:
The cost is an arbitrary attribute to indicate if the information is retrieved from a wfs query (cost = 1), or from an xml (cost = 10)
In [7]:
# if an attribute can have several values, these are listed under 'values', e.g. for 'Type_proef':
fields['Type_proef']
Out[7]:
In [8]:
from pydov.util.location import Within, Box
# Get all borehole data in a bounding box (llx, lly, ulx, uly)
# the pkey_boring link is not available below, but is in the df
df = ip_hydrogeo.search(location=Within(Box(153145, 206930, 153150, 206935)))
print(df.head())
In [9]:
# list available query methods
methods = [i for i,j in inspect.getmembers(sys.modules['owslib.fes'],
inspect.isclass)
if 'Property' in i]
print(methods)
from owslib.fes import PropertyIsGreaterThanOrEqualTo
The property feature methodes listed above are available from the owslib module. These were not adapted for use in pydov.
In [10]:
# Get deep boreholes in a bounding box
from owslib.fes import PropertyIsEqualTo
# the propertyname can be any of the fields of the hydrogeological interpretations object that belong to the wfs source
# the literal is always a string, no matter what its definition is in the boring object (string, float...)
query = PropertyIsGreaterThanOrEqualTo(
propertyname='betrouwbaarheid_interpretatie', literal='goed')
df = ip_hydrogeo.search(location=Within(Box(153145, 206930, 153150, 206935)),
query=query
)
print(df.head())
In [11]:
query = PropertyIsEqualTo(propertyname='gemeente',
literal='Aartselaar')
df = ip_hydrogeo.search(query=query)
print(df.head())
To keep the dataframe size acceptable, not all wfs fields are included in the standard output. However, one can use this information to select interpretations as illustrated below. The available wfs fields can be viewed in the object catalog of the 'Hydrogeologische stratigrafie' wfs service, on-line [2018 05 16]: https://www.dov.vlaanderen.be/geonetwork/apps/tabsearch/index.html?hl=dut. For example, make a selection of the interpretations in the municipality of Antwerp that were derived from cpt data
In [12]:
from owslib.fes import And
from owslib.fes import PropertyIsEqualTo
query = And([PropertyIsEqualTo(propertyname='gemeente',
literal='Antwerpen'),
PropertyIsEqualTo(propertyname='Type_proef',
literal='Boring')]
)
df = ip_hydrogeo.search(query=query, )
print(df.head())
Using Folium, we can display the results of our search on a map.
In [16]:
# import the necessary modules (not included in the requirements of pydov!)
import folium
from folium.plugins import MarkerCluster
from pyproj import Transformer
In [17]:
# convert the coordinates to lat/lon for folium
def convert_latlon(x1, y1):
transformer = Transformer.from_crs("epsg:31370", "epsg:4326", always_xy=True)
x2,y2 = transformer.transform(x1, y1)
return x2, y2
df['lon'], df['lat'] = zip(*map(convert_latlon, df['x'], df['y']))
# convert to list
loclist = df[['lat', 'lon']].values.tolist()
In [18]:
# initialize the Folium map on the centre of the selected locations, play with the zoom until ok# initia
fmap = folium.Map(location=[df['lat'].mean(), df['lon'].mean()], zoom_start=12)
marker_cluster = MarkerCluster().add_to(fmap)
for loc in range(0, len(loclist)):
folium.Marker(loclist[loc], popup=df['aquifer'][loc]).add_to(marker_cluster)
fmap
Out[18]: