In [1]:
%matplotlib inline
import os, sys
import inspect
In [2]:
import pydov
In [3]:
from pydov.search.interpretaties import LithologischeBeschrijvingenSearch
ip_litho = LithologischeBeschrijvingenSearch()
# information about the HydrogeologischeStratigrafie type (In Dutch):
ip_litho.get_description()
Out[3]:
In [4]:
# information about the available fields for a HydrogeologischeStratigrafie object
fields = ip_litho.get_fields()
# print available fields
for f in fields.values():
print(f['name'])
In [5]:
# print information for a certain field
fields['beschrijving']
Out[5]:
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 [6]:
# if an attribute can have several values, these are listed under 'values', e.g. for 'Type_proef':
fields['Type_proef']
Out[6]:
In [7]:
from pydov.util.location import Within, Box
# Get all lithological descriptions in a bounding box (llx, lly, ulx, uly)
# the pkey_boring link is not available below, but is in the df
df = ip_litho.search(location=Within(Box(152145, 204930, 153150, 206935)))
df = df[df.beschrijving.notnull()]
df.head()
Out[7]:
In [8]:
# list available query methods
methods = [i for i,j in inspect.getmembers(sys.modules['owslib.fes'],
inspect.isclass)
if 'Property' in i]
methods
Out[8]:
In [9]:
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_litho.search(location=Within(Box(153145, 206930, 153150, 206935)),
query=query
)
df.head()
Out[10]:
In [11]:
query = PropertyIsEqualTo(propertyname='gemeente',
literal='Aartselaar')
df = ip_litho.search(query=query)
df.head()
Out[11]:
Using Folium, we can display the results of our search on a map.
In [12]:
# import the necessary modules (not included in the requirements of pydov!)
import folium
from folium.plugins import MarkerCluster
from pyproj import Transformer
In [13]:
# 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 [14]:
# initialize the Folium map on the centre of the selected locations, play with the zoom until ok
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)):
# limit marker size for folium (:10)
folium.Marker(loclist[loc], popup=df['beschrijving'][loc][:10]).add_to(marker_cluster)
fmap
Out[14]: