In [1]:
%matplotlib inline
import os, sys
import inspect
In [2]:
# check pydov path
import pydov
In [4]:
from pydov.search.interpretaties import QuartairStratigrafieSearch
# information about the QuartairStratigrafie type (In Dutch):
ip_quart = QuartairStratigrafieSearch()
ip_quart.get_description()
Out[4]:
In [5]:
# information about the available fields for a QuartairStratigrafie object
fields = ip_quart.get_fields()
# print available fields
for f in fields.values():
print(f['name'])
In [6]:
# print information for a certain field
fields['Type_proef']
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 [8]:
from pydov.util.location import Within, Box
# Get all interpretations in a bounding box (llx, lly, ulx, uly)
# the pkey_boring link is not available below, but is in the df
df = ip_quart.search(location=Within(Box(132815, 191700, 133815, 192700)))
df.head()
Out[8]:
In [11]:
# list available query methods
methods = [i for i,j in inspect.getmembers(sys.modules['owslib.fes'],
inspect.isclass)
if 'Property' in i]
methods
Out[11]:
In [12]:
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 [15]:
# Get deep boreholes in a bounding box
from owslib.fes import PropertyIsLike
# the propertyname can be any of the fields of the 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 = PropertyIsLike(
propertyname='betrouwbaarheid_interpretatie', literal='onbekend')
df = ip_quart.search(location=Within(Box(132815, 191700, 133815, 192700)),
query=query
)
df.head()
Out[15]:
In [18]:
from pydov.util.location import Point, WithinDistance
# Get all interpretations within a defined distance from a point
location = WithinDistance(location=Point(133000, 192000),
distance=1000, distance_unit='meter')
df = ip_quart.search(location=location)
df.head()
Out[18]:
In [19]:
from owslib.fes import PropertyIsEqualTo
query = PropertyIsEqualTo(propertyname='gemeente',
literal='Hamme')
df = ip_quart.search(query=query)
df.head()
Out[19]:
Using Folium, we can display the results of our search on a map.
In [22]:
# import the necessary modules (not included in the requirements of pydov!)
import folium
from folium.plugins import MarkerCluster
from pyproj import Transformer
# for windows 10 users, we could not get it working with Microsoft Edge
# change the browser to Chrome in the Notebook config file instead
In [23]:
# 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 [24]:
# 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)):
folium.Marker(loclist[loc], popup=df['lid1'][loc]).add_to(marker_cluster)
fmap
Out[24]:
In [ ]: