Example of DOV search methods for interpretations (informele stratigrafie)

Binder

Use cases explained below

  • Get ‘informele stratigrafie’ in a bounding box

  • Get ‘informele stratigrafie’ with specific properties

  • Get ‘informele stratigrafie’ in a bounding box based on specific properties

  • Select ‘informele stratigrafie’ in a municipality and return date

  • Get ‘informele stratigrafie’ based on fields not available in the standard output dataframe

  • Get ‘informele stratigrafie’ data, returning fields not available in the standard output dataframe

[1]:
%matplotlib inline
import inspect, sys
[2]:
# check pydov path
import pydov

Get information about the datatype ‘Informele stratigrafie’

[3]:
from pydov.search.interpretaties import InformeleStratigrafieSearch
itp = InformeleStratigrafieSearch()

A description is provided for the ‘Informele stratigrafie’ datatype:

[4]:
itp.get_description()
[4]:
'Een informele stratigrafie van een boring is, net als een formele stratigrafie, een lithostratigrafische interpretatie van een (gecodeerde) lithologische beschrijving per diepte-interval. Het verschil met de formele stratigrafie is dat de informele stratigrafie niet moet voldoen aan een algemeen aanvaarde standaard. De informele stratigrafie is een plaats in DOV om oude interpretaties of interpretaties die niet voldoen aan de huidige stratigrafische indeling toch weer te geven. De informele stratigrafie kan ook een gedetailleerde beschrijving bevatten van een lithostratigrafische eenheid.'

The different fields that are available for objects of the ‘Informele stratigrafie’ datatype can be requested with the get_fields() method:

[5]:
fields = itp.get_fields()

# print available fields
for f in fields.values():
    print(f['name'])
pkey_interpretatie
Type_proef
Proefnummer
Proeffiche
x
y
start_interpretatie_mtaw
diepte_tot_m
gemeente
Auteurs
Datum
Opdrachten
betrouwbaarheid_interpretatie
Geldig_van
Geldig_tot
eerste_invoer
geom
diepte_laag_van
diepte_laag_tot
beschrijving
pkey_boring
pkey_sondering

You can get more information of a field by requesting it from the fields dictionary:

  • name: name of the field

  • definition: definition of this field

  • cost: currently this is either 1 or 10, depending on the datasource of the field. It is an indication of the expected time it will take to retrieve this field in the output dataframe.

  • notnull: whether the field is mandatory or not

  • type: datatype of the values of this field

Alternatively, you can list all the fields and their details by inspecting the get_fields() output or the search instance itself in a notebook:

[6]:
itp
[6]:
pydov.search.interpretaties.InformeleStratigrafieSearch

Een informele stratigrafie van een boring is, net als een formele stratigrafie, een lithostratigrafische interpretatie van een (gecodeerde) lithologische beschrijving per diepte-interval. Het verschil met de formele stratigrafie is dat de informele stratigrafie niet moet voldoen aan een algemeen aanvaarde standaard. De informele stratigrafie is een plaats in DOV om oude interpretaties of interpretaties die niet voldoen aan de huidige stratigrafische indeling toch weer te geven. De informele stratigrafie kan ook een gedetailleerde beschrijving bevatten van een lithostratigrafische eenheid.

pkey_interpretatie - URL die verwijst naar de gegevens van deze informele stratigrafie op de website. Voeg '.xml' toe om een XML voorstelling van deze gegevens te verkrijgen.

  • type: string
  • notnull: False
  • query: True
  • cost: 1
  • multivalue: False

Type_proef - Het type van de proef waarvan de informele stratigrafie een interpretatie is.

  • type: string
  • notnull: False
  • query: True
  • cost: 1
  • multivalue: False
  • codelist:
  • pydov.util.codelists.FeatureCatalogueValues

    Boring - Boring - De informele stratigrafie is een interpretatie van een boring.

    Sondering - Sondering - De informele stratigrafie is een interpretatie van een sondering.

Proefnummer - Het proefnummer van de proef (boring of sondering) waarvan de informele stratigrafie een interpretatie is.

  • type: string
  • notnull: False
  • query: True
  • cost: 1
  • multivalue: False

Proeffiche - URL die verwijst naar de gegevens van de proef (boring of sondering) op de website. Voeg '.xml' toe om een XML voorstelling van deze gegevens te verkrijgen.

  • type: string
  • notnull: False
  • query: True
  • cost: 1
  • multivalue: False

x - De x-coördinaat van de proef in het Lambert72 coördinaatsysteem (in meter, EPSG:31370).

  • type: float
  • notnull: False
  • query: True
  • cost: 1
  • multivalue: False

y - De y-coördinaat van de proef in het Lambert72 coördinaatsysteem (in meter, EPSG:31370).

  • type: float
  • notnull: False
  • query: True
  • cost: 1
  • multivalue: False

start_interpretatie_mtaw - De hoogte van het aanvangspeil van de proef in het TAW stelsel (in meter).

  • type: float
  • notnull: False
  • query: True
  • cost: 1
  • multivalue: False

diepte_tot_m - De maximumdiepte van de informele stratigrafie in meter. Dit is de 'tot' van de diepste geïnterpreteerde laag.

  • type: float
  • notnull: False
  • query: True
  • cost: 1
  • multivalue: False

gemeente - De gemeente waarin de proef van deze interpretatie gelegen is.

  • type: string
  • notnull: False
  • query: True
  • cost: 1
  • multivalue: False

Auteurs - De auteur of auteurs van de informele stratigrafie.

  • type: string
  • notnull: False
  • query: True
  • cost: 1
  • multivalue: False

Datum - De datum waarop de informele stratigrafie werd beschreven.

  • type: date
  • notnull: False
  • query: True
  • cost: 1
  • multivalue: False

Opdrachten - De opdracht(en) waaraan de informele stratigrafie gekoppeld is.

  • type: string
  • notnull: False
  • query: True
  • cost: 1
  • multivalue: False

betrouwbaarheid_interpretatie - De betrouwbaarheid van het geheel van de informele stratigrafie (goed, twijfelachtig of onbekend). Deze wordt toegekend door een DOV-medewerker verantwoordelijk voor de ingave.

  • type: string
  • notnull: False
  • query: True
  • cost: 1
  • multivalue: False

Geldig_van - Het tijdstip vanaf wanneer de informele stratigrafie geldig is.

  • type: date
  • notnull: False
  • query: True
  • cost: 1
  • multivalue: False

Geldig_tot - Het tijdstip tot wanneer de informele stratigrafie geldig is.

  • type: date
  • notnull: False
  • query: True
  • cost: 1
  • multivalue: False

eerste_invoer - Het tijdstip waarop deze interpretatie voor het eerst in DOV ingevoerd werd.

  • type: datetime
  • notnull: True
  • query: True
  • cost: 1
  • multivalue: False

geom - None

  • type: geometry
  • notnull: False
  • query: False
  • cost: 1
  • multivalue: False

diepte_laag_van - Diepte van de bovenkant van de laag informele stratigrafie in meter.

  • type: float
  • notnull: False
  • query: False
  • cost: 10
  • multivalue: False

diepte_laag_tot - Diepte van de onderkant van de laag informele stratigrafie in meter.

  • type: float
  • notnull: False
  • query: False
  • cost: 10
  • multivalue: False

beschrijving - Benoeming van de eenheid van de laag informele stratigrafie in vrije tekst (onbeperkt in lengte).

  • type: string
  • notnull: False
  • query: False
  • cost: 10
  • multivalue: False

pkey_boring - URL die verwijst naar de gegevens van de boring waaraan deze interpretatie gekoppeld is (indien gekoppeld aan een boring).

  • type: string
  • notnull: False
  • query: False
  • cost: 1
  • multivalue: False

pkey_sondering - URL die verwijst naar de gegevens van de sondering waaraan deze interpretatie gekoppeld is (indien gekoppeld aan een sondering).

  • type: string
  • notnull: False
  • query: False
  • cost: 1
  • multivalue: False

Example use cases

Get ‘informele stratigrafie’ in a bounding box

Get data for all the ‘informele stratigrafie’ interpretations that are geographically located within the bounds of the specified box.

The coordinates are in the Belgian Lambert72 (EPSG:31370) coordinate system and are given in the order of lower left x, lower left y, upper right x, upper right y.

[7]:
from pydov.util.location import Within, Box

df = itp.search(location=Within(Box(153145, 206930, 153150, 206935, epsg=31370)))
df.head()
[000/001] .
[000/001] .
[7]:
pkey_interpretatie pkey_boring pkey_sondering betrouwbaarheid_interpretatie x y start_interpretatie_mtaw diepte_laag_van diepte_laag_tot beschrijving
0 https://www.dov.vlaanderen.be/data/interpretat... https://www.dov.vlaanderen.be/data/boring/1974... NaN goed 153147.0 206931.0 14.12 0.0 3.00 Quartair
1 https://www.dov.vlaanderen.be/data/interpretat... https://www.dov.vlaanderen.be/data/boring/1974... NaN goed 153147.0 206931.0 14.12 3.0 14.05 Tertiair - Mioceen: Antwerpiaan

The dataframe contains one ‘informele stratigrafie’ interpretation where three layers (‘laag’) were identified. The available data are flattened to represent unique attributes per row of the dataframe.

Using the pkey_interpretatie field one can request the details of this interpretation in a webbrowser:

[8]:
for pkey_interpretatie in set(df.pkey_interpretatie):
    print(pkey_interpretatie)
https://www.dov.vlaanderen.be/data/interpretatie/1975-213484

Get ‘informele stratigrafie’ with specific properties

Next to querying interpretations based on their geographic location within a bounding box, we can also search for interpretations matching a specific set of properties. For this we can build a query using a combination of the ‘InformeleStratigrafie’ fields and operators provided by the WFS protocol.

A list of possible operators can be found below:

[9]:
[i for i,j in inspect.getmembers(sys.modules['owslib.fes2'], inspect.isclass) if 'Property' in i]
[9]:
['PropertyIsBetween',
 'PropertyIsEqualTo',
 'PropertyIsGreaterThan',
 'PropertyIsGreaterThanOrEqualTo',
 'PropertyIsLessThan',
 'PropertyIsLessThanOrEqualTo',
 'PropertyIsLike',
 'PropertyIsNotEqualTo',
 'PropertyIsNull',
 'SortProperty']

In this example we build a query using the PropertyIsEqualTo operator to find all interpretations that are within the community (gemeente) of ‘Herstappe’:

[10]:
from owslib.fes2 import PropertyIsEqualTo

query = PropertyIsEqualTo(propertyname='gemeente',
                          literal='Herstappe')
df = itp.search(query=query)

df.head()
[000/001] .
[000/003] ...
[10]:
pkey_interpretatie pkey_boring pkey_sondering betrouwbaarheid_interpretatie x y start_interpretatie_mtaw diepte_laag_van diepte_laag_tot beschrijving
0 https://www.dov.vlaanderen.be/data/interpretat... https://www.dov.vlaanderen.be/data/boring/2016... NaN goed 224687.4 158191.0 124.0 0.00 3.75 q2
1 https://www.dov.vlaanderen.be/data/interpretat... https://www.dov.vlaanderen.be/data/boring/2016... NaN goed 224687.4 158191.0 124.0 3.75 6.00 q1c
2 https://www.dov.vlaanderen.be/data/interpretat... https://www.dov.vlaanderen.be/data/boring/1993... NaN goed 224820.0 157794.0 132.0 0.00 50.00 ?
3 https://www.dov.vlaanderen.be/data/interpretat... https://www.dov.vlaanderen.be/data/boring/1993... NaN goed 224820.0 157794.0 132.0 5.00 50.00 Formatie van Gulpen

Once again we can use the pkey_interpretatie as a permanent link to the information of these interpretations:

[11]:
for pkey_interpretatie in set(df.pkey_interpretatie):
    print(pkey_interpretatie)
https://www.dov.vlaanderen.be/data/interpretatie/1993-097697
https://www.dov.vlaanderen.be/data/interpretatie/2010-106477
https://www.dov.vlaanderen.be/data/interpretatie/2016-271517

Get ‘informele stratigrafie’ in a bounding box based on specific properties

We can combine a query on attributes with a query on geographic location to get the interpretations within a bounding box that have specific properties.

The following example requests the interpretations of boreholes only, within the given bounding box.

(Note that the datatype of the literal parameter should be a string, regardless of the datatype of this field in the output dataframe.)

[12]:
from owslib.fes2 import PropertyIsEqualTo

query = PropertyIsEqualTo(
            propertyname='Type_proef',
            literal='Boring')

df = itp.search(
    location=Within(Box(205000, 205000, 206000, 206000, epsg=31370)),
    query=query
    )

df.head()
[000/001] .
[000/003] ...
[12]:
pkey_interpretatie pkey_boring pkey_sondering betrouwbaarheid_interpretatie x y start_interpretatie_mtaw diepte_laag_van diepte_laag_tot beschrijving
0 https://www.dov.vlaanderen.be/data/interpretat... https://www.dov.vlaanderen.be/data/boring/1896... NaN goed 205952.9 205993.0 33.00 0.0 1.0 R
1 https://www.dov.vlaanderen.be/data/interpretat... https://www.dov.vlaanderen.be/data/boring/1896... NaN goed 205952.9 205993.0 33.00 1.0 2.3 q4
2 https://www.dov.vlaanderen.be/data/interpretat... https://www.dov.vlaanderen.be/data/boring/1896... NaN goed 205970.0 205270.5 34.00 0.0 2.3 q4
3 https://www.dov.vlaanderen.be/data/interpretat... https://www.dov.vlaanderen.be/data/boring/1975... NaN goed 205264.2 205607.5 33.38 0.0 8.0 Kwartair

We can look at one of the interpretations in a webbrowser using its pkey_interpretatie:

[13]:
for pkey_interpretatie in set(df.pkey_interpretatie):
    print(pkey_interpretatie)
https://www.dov.vlaanderen.be/data/interpretatie/1896-044150
https://www.dov.vlaanderen.be/data/interpretatie/1975-044576
https://www.dov.vlaanderen.be/data/interpretatie/1896-044149

Select ‘informele stratigrafie’ in a municipality and return date

We can limit the columns in the output dataframe by specifying the return_fields parameter in our search.

In this example we query all the ‘informele stratigrafie’ interpretations in the city of Ghent and return their date:

[15]:
from owslib.fes2 import And, Not, PropertyIsNull

query = And([
    PropertyIsEqualTo(propertyname='gemeente',
                          literal='Gent'),
    Not([PropertyIsNull('Datum')])
])

df = itp.search(query=query,
                return_fields=('Datum',))
df.head()
[000/001] .
[15]:
Datum
0 1991-02-28
1 1991-03-01
2 1991-03-05
3 1991-03-06
4 1991-03-12
[16]:
df.describe()
[16]:
Datum
count 560
unique 245
top 1996-11-25
freq 41

Get ‘informele stratigrafie’ based on fields not available in the standard output dataframe

To keep the output dataframe size acceptable, not all available WFS fields are included in the standard output. However, one can use this information to select interpretations as illustrated below.

For example, make a selection of the interpretations in municipality the of Antwerp, before 1/1/1900:

[17]:
from owslib.fes2 import And, PropertyIsEqualTo, PropertyIsLessThan

query = And([PropertyIsEqualTo(propertyname='gemeente',
                               literal='Antwerpen'),
             PropertyIsLessThan(propertyname='Datum',
                                 literal='1900-01-01')]
            )
df = itp.search(query=query,
                return_fields=('pkey_interpretatie', 'Datum'))
df.head()
[000/001] .
[17]:
pkey_interpretatie Datum
0 https://www.dov.vlaanderen.be/data/interpretat... 1895-05-21
1 https://www.dov.vlaanderen.be/data/interpretat... 1895-05-21
2 https://www.dov.vlaanderen.be/data/interpretat... 1895-05-21
3 https://www.dov.vlaanderen.be/data/interpretat... 1895-05-21
4 https://www.dov.vlaanderen.be/data/interpretat... 1895-05-21

Get ‘informele stratigrafie’ data, returning fields not available in the standard output dataframe

As denoted in the previous example, not all available fields are available in the default output frame to keep its size limited. However, you can request any available field by including it in the return_fields parameter of the search:

[18]:
query = PropertyIsEqualTo(
            propertyname='gemeente',
            literal='Herstappe')

df = itp.search(query=query,
                return_fields=('pkey_interpretatie', 'pkey_boring', 'pkey_sondering',
                               'x', 'y', 'start_interpretatie_mtaw', 'gemeente', 'Auteurs', 'Proefnummer'))

df.head()
[000/001] .
[18]:
pkey_interpretatie pkey_boring pkey_sondering x y start_interpretatie_mtaw gemeente Auteurs Proefnummer
0 https://www.dov.vlaanderen.be/data/interpretat... https://www.dov.vlaanderen.be/data/boring/2016... NaN 224687.4 158191.0 124.0 Herstappe Rutot, A. - Belgische Geologische Dienst (BGD) kb33d106e-B236
1 https://www.dov.vlaanderen.be/data/interpretat... https://www.dov.vlaanderen.be/data/boring/1993... NaN 224820.0 157794.0 132.0 Herstappe Boormeester, - bedrijf-dienst onbekend kb41d120e-B1027
2 https://www.dov.vlaanderen.be/data/interpretat... https://www.dov.vlaanderen.be/data/boring/1993... NaN 224820.0 157794.0 132.0 Herstappe Lagrou, David - VLAKO kb41d120e-B1027

Visualize results

Using Folium, we can display the results of our search on a map.

[19]:
# import the necessary modules (not included in the requirements of pydov!)
import folium
from folium.plugins import MarkerCluster
from pyproj import Transformer
[20]:
# 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()
[21]:
# 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['Proefnummer'][loc]).add_to(marker_cluster)
fmap

[21]:
Make this Notebook Trusted to load map: File -> Trust Notebook