{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Example of DOV search methods for interpretations (informele hydrogeologische stratigrafie)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/DOV-Vlaanderen/pydov/master?filepath=docs%2Fnotebooks%2Fsearch_informele_hydrostratigrafie.ipynb)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Use cases explained below\n", "* Get 'informele hydrogeologische stratigrafie' in a bounding box\n", "* Get 'informele hydrogeologische stratigrafie' with specific properties\n", "* Get 'informele hydrogeologische stratigrafie' in a bounding box based on specific properties\n", "* Select 'informele hydrogeologische stratigrafie' in a municipality and return date\n", "* Get 'informele hydrogeologische stratigrafie' based on fields not available in the standard output dataframe\n", "* Get 'informele hydrogeologische stratigrafie' data, returning fields not available in the standard output dataframe" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "%matplotlib inline\n", "import inspect, sys" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "# check pydov path\n", "import pydov" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Get information about the datatype 'Informele hydrogeologische stratigrafie'" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "from pydov.search.interpretaties import InformeleHydrogeologischeStratigrafieSearch\n", "itp = InformeleHydrogeologischeStratigrafieSearch()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "A description is provided for the 'Informele stratigrafie' datatype:" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'Een informele hydrogeologische stratigrafie van een boring geeft, op basis van de (gecodeerde) lithologie, een indeling weer naar de al dan niet watervoerende eigenschappen van een bepaald beschreven diepte-interval. \\r\\nHet verschil met de hydrogeologische stratigrafie is dat voor de informele hydrogeologische stratigrafie geen algemene standaard gebruikt wordt. Bij de hydrogeologische stratigrafie wordt de Hydrogeologische Codering van de Ondergrond van Vlaanderen (HCOV). Deze kan beschouwd worden als de officiele hydrogeologische codering voor het Vlaams Gewest.'" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "itp.get_description()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The different fields that are available for objects of the 'Informele hydrogeologische stratigrafie' datatype can be requested with the get_fields() method:" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "pkey_interpretatie\n", "Type_proef\n", "Proefnummer\n", "pkey_boring\n", "x\n", "y\n", "start_interpretatie_mtaw\n", "diepte_tot_m\n", "gemeente\n", "Auteurs\n", "Datum\n", "Opdrachten\n", "betrouwbaarheid_interpretatie\n", "Geldig_van\n", "Geldig_tot\n", "eerste_invoer\n", "geom\n", "diepte_laag_van\n", "diepte_laag_tot\n", "beschrijving\n" ] } ], "source": [ "fields = itp.get_fields()\n", "\n", "# print available fields\n", "for f in fields.values():\n", " print(f['name'])" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "You can get more information of a field by requesting it from the fields dictionary:\n", "* *name*: name of the field\n", "* *definition*: definition of this field\n", "* *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.\n", "* *notnull*: whether the field is mandatory or not\n", "* *type*: datatype of the values of this field\n", "\n", "Alternatively, you can list all the fields and their details by inspecting the `get_fields()` output or the search instance itself in a notebook:" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", " \n", "
\n", " \n", "
\n", " pydov.search.interpretaties.InformeleHydrogeologischeStratigrafieSearch\n", "
\n", "

Een informele hydrogeologische stratigrafie van een boring geeft, op basis van de (gecodeerde) lithologie, een indeling weer naar de al dan niet watervoerende eigenschappen van een bepaald beschreven diepte-interval. \r\n", "Het verschil met de hydrogeologische stratigrafie is dat voor de informele hydrogeologische stratigrafie geen algemene standaard gebruikt wordt. Bij de hydrogeologische stratigrafie wordt de Hydrogeologische Codering van de Ondergrond van Vlaanderen (HCOV). Deze kan beschouwd worden als de officiele hydrogeologische codering voor het Vlaams Gewest.

\n", " \n", "
\n", "

pkey_interpretatie - URL die verwijst naar de gegevens van deze informele hydrogeologische 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
\n", "
\n", " \n", " \n", "
\n", "

Type_proef - Het type van de proef waarvan de informele hydrogeologische stratigrafie een interpretatie is. Bij een informele hydrogeologische stratigrafie zal dit altijd 'Boring' zijn.

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

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

    \n", "
    \n", " \n", "
    \n", "
\n", "
\n", " \n", " \n", "
\n", "

Proefnummer - Het proefnummer van de boring waarvan de informele hydrogeologische stratigrafie een interpretatie is.

  • type: string
  • notnull: False
  • query: True
  • cost: 1
  • multivalue: False
\n", "
\n", " \n", " \n", "
\n", "

pkey_boring - URL die verwijst naar de gegevens van de boring 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
\n", "
\n", " \n", " \n", "
\n", "

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

  • type: float
  • notnull: False
  • query: True
  • cost: 1
  • multivalue: False
\n", "
\n", " \n", " \n", "
\n", "

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

  • type: float
  • notnull: False
  • query: True
  • cost: 1
  • multivalue: False
\n", "
\n", " \n", " \n", "
\n", "

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

  • type: float
  • notnull: False
  • query: True
  • cost: 1
  • multivalue: False
\n", "
\n", " \n", " \n", "
\n", "

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

  • type: float
  • notnull: False
  • query: True
  • cost: 1
  • multivalue: False
\n", "
\n", " \n", " \n", "
\n", "

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

  • type: string
  • notnull: False
  • query: True
  • cost: 1
  • multivalue: False
\n", "
\n", " \n", " \n", "
\n", "

Auteurs - De auteur of auteurs van de informele hydrogeologische stratigrafie.

  • type: string
  • notnull: False
  • query: True
  • cost: 1
  • multivalue: False
\n", "
\n", " \n", " \n", "
\n", "

Datum - De datum waarop de informele hydrogeologische stratigrafie werd beschreven.

  • type: date
  • notnull: False
  • query: True
  • cost: 1
  • multivalue: False
\n", "
\n", " \n", " \n", "
\n", "

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

  • type: string
  • notnull: False
  • query: True
  • cost: 1
  • multivalue: False
\n", "
\n", " \n", " \n", "
\n", "

betrouwbaarheid_interpretatie - De betrouwbaarheid van het geheel van de informele hydrogeologische 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
\n", "
\n", " \n", " \n", "
\n", "

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

  • type: date
  • notnull: False
  • query: True
  • cost: 1
  • multivalue: False
\n", "
\n", " \n", " \n", "
\n", "

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

  • type: date
  • notnull: False
  • query: True
  • cost: 1
  • multivalue: False
\n", "
\n", " \n", " \n", "
\n", "

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

  • type: datetime
  • notnull: True
  • query: True
  • cost: 1
  • multivalue: False
\n", "
\n", " \n", " \n", "
\n", "

geom - None

  • type: geometry
  • notnull: False
  • query: False
  • cost: 1
  • multivalue: False
\n", "
\n", " \n", " \n", "
\n", "

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

  • type: float
  • notnull: False
  • query: False
  • cost: 10
  • multivalue: False
\n", "
\n", " \n", " \n", "
\n", "

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

  • type: float
  • notnull: False
  • query: False
  • cost: 10
  • multivalue: False
\n", "
\n", " \n", " \n", "
\n", "

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

  • type: string
  • notnull: False
  • query: False
  • cost: 10
  • multivalue: False
\n", "
\n", "

\n", "
\n", " " ], "text/plain": [ "" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "itp" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Example use cases" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Get 'informele hydrogeologische stratigrafie' in a bounding box" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Get data for all the 'informele hydrogeologisch stratigrafie' interpretations that are geographically located within the bounds of the specified box.\n", "\n", "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." ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[000/001] .\n", "[000/001] .\n" ] }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
pkey_interpretatiepkey_boringbetrouwbaarheid_interpretatiexystart_interpretatie_mtawdiepte_laag_vandiepte_laag_totbeschrijving
0https://www.dov.vlaanderen.be/data/interpretat...https://www.dov.vlaanderen.be/data/boring/1981...goed172148.5182587.510.940.02.5QUARTAIR
1https://www.dov.vlaanderen.be/data/interpretat...https://www.dov.vlaanderen.be/data/boring/1981...goed172148.5182587.510.942.513.6FORMATIE VAN MALDEGEM
2https://www.dov.vlaanderen.be/data/interpretat...https://www.dov.vlaanderen.be/data/boring/1981...goed172148.5182587.510.9413.625.5FORMATIE VAN MALDEGEM (Lid van Wemmel)
3https://www.dov.vlaanderen.be/data/interpretat...https://www.dov.vlaanderen.be/data/boring/1981...goed172148.5182587.510.9425.533.2FORMATIE VAN LEDE
4https://www.dov.vlaanderen.be/data/interpretat...https://www.dov.vlaanderen.be/data/boring/1981...goed172148.5182587.510.9433.267.3FORMATIE VAN BRUSSEL
\n", "
" ], "text/plain": [ " pkey_interpretatie \\\n", "0 https://www.dov.vlaanderen.be/data/interpretat... \n", "1 https://www.dov.vlaanderen.be/data/interpretat... \n", "2 https://www.dov.vlaanderen.be/data/interpretat... \n", "3 https://www.dov.vlaanderen.be/data/interpretat... \n", "4 https://www.dov.vlaanderen.be/data/interpretat... \n", "\n", " pkey_boring \\\n", "0 https://www.dov.vlaanderen.be/data/boring/1981... \n", "1 https://www.dov.vlaanderen.be/data/boring/1981... \n", "2 https://www.dov.vlaanderen.be/data/boring/1981... \n", "3 https://www.dov.vlaanderen.be/data/boring/1981... \n", "4 https://www.dov.vlaanderen.be/data/boring/1981... \n", "\n", " betrouwbaarheid_interpretatie x y start_interpretatie_mtaw \\\n", "0 goed 172148.5 182587.5 10.94 \n", "1 goed 172148.5 182587.5 10.94 \n", "2 goed 172148.5 182587.5 10.94 \n", "3 goed 172148.5 182587.5 10.94 \n", "4 goed 172148.5 182587.5 10.94 \n", "\n", " diepte_laag_van diepte_laag_tot beschrijving \n", "0 0.0 2.5 QUARTAIR \n", "1 2.5 13.6 FORMATIE VAN MALDEGEM \n", "2 13.6 25.5 FORMATIE VAN MALDEGEM (Lid van Wemmel) \n", "3 25.5 33.2 FORMATIE VAN LEDE \n", "4 33.2 67.3 FORMATIE VAN BRUSSEL " ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from pydov.util.location import Within, Box\n", "\n", "df = itp.search(location=Within(Box(100000, 100000, 200000, 200000, epsg=31370)))\n", "df.head()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "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.\n", "\n", "Using the *pkey_interpretatie* field one can request the details of this interpretation in a webbrowser:" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "https://www.dov.vlaanderen.be/data/interpretatie/1981-217464\n" ] } ], "source": [ "for pkey_interpretatie in set(df.pkey_interpretatie):\n", " print(pkey_interpretatie)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Get 'informele hydrogeologische stratigrafie' with specific properties" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "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 'InformeleHydrogeologischeStratigrafie' fields and operators provided by the WFS protocol.\n", "\n", "A list of possible operators can be found below:" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "['PropertyIsBetween',\n", " 'PropertyIsEqualTo',\n", " 'PropertyIsGreaterThan',\n", " 'PropertyIsGreaterThanOrEqualTo',\n", " 'PropertyIsLessThan',\n", " 'PropertyIsLessThanOrEqualTo',\n", " 'PropertyIsLike',\n", " 'PropertyIsNotEqualTo',\n", " 'PropertyIsNull',\n", " 'SortProperty']" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "[i for i,j in inspect.getmembers(sys.modules['owslib.fes2'], inspect.isclass) if 'Property' in i]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "In this example we build a query using the *PropertyIsEqualTo* operator to find all interpretations that are within the community (gemeente) of 'Herstappe':" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[000/001] .\n", "[000/001] c\n" ] }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
pkey_interpretatiepkey_boringbetrouwbaarheid_interpretatiexystart_interpretatie_mtawdiepte_laag_vandiepte_laag_totbeschrijving
0https://www.dov.vlaanderen.be/data/interpretat...https://www.dov.vlaanderen.be/data/boring/1981...goed172148.5182587.510.940.02.5QUARTAIR
1https://www.dov.vlaanderen.be/data/interpretat...https://www.dov.vlaanderen.be/data/boring/1981...goed172148.5182587.510.942.513.6FORMATIE VAN MALDEGEM
2https://www.dov.vlaanderen.be/data/interpretat...https://www.dov.vlaanderen.be/data/boring/1981...goed172148.5182587.510.9413.625.5FORMATIE VAN MALDEGEM (Lid van Wemmel)
3https://www.dov.vlaanderen.be/data/interpretat...https://www.dov.vlaanderen.be/data/boring/1981...goed172148.5182587.510.9425.533.2FORMATIE VAN LEDE
4https://www.dov.vlaanderen.be/data/interpretat...https://www.dov.vlaanderen.be/data/boring/1981...goed172148.5182587.510.9433.267.3FORMATIE VAN BRUSSEL
\n", "
" ], "text/plain": [ " pkey_interpretatie \\\n", "0 https://www.dov.vlaanderen.be/data/interpretat... \n", "1 https://www.dov.vlaanderen.be/data/interpretat... \n", "2 https://www.dov.vlaanderen.be/data/interpretat... \n", "3 https://www.dov.vlaanderen.be/data/interpretat... \n", "4 https://www.dov.vlaanderen.be/data/interpretat... \n", "\n", " pkey_boring \\\n", "0 https://www.dov.vlaanderen.be/data/boring/1981... \n", "1 https://www.dov.vlaanderen.be/data/boring/1981... \n", "2 https://www.dov.vlaanderen.be/data/boring/1981... \n", "3 https://www.dov.vlaanderen.be/data/boring/1981... \n", "4 https://www.dov.vlaanderen.be/data/boring/1981... \n", "\n", " betrouwbaarheid_interpretatie x y start_interpretatie_mtaw \\\n", "0 goed 172148.5 182587.5 10.94 \n", "1 goed 172148.5 182587.5 10.94 \n", "2 goed 172148.5 182587.5 10.94 \n", "3 goed 172148.5 182587.5 10.94 \n", "4 goed 172148.5 182587.5 10.94 \n", "\n", " diepte_laag_van diepte_laag_tot beschrijving \n", "0 0.0 2.5 QUARTAIR \n", "1 2.5 13.6 FORMATIE VAN MALDEGEM \n", "2 13.6 25.5 FORMATIE VAN MALDEGEM (Lid van Wemmel) \n", "3 25.5 33.2 FORMATIE VAN LEDE \n", "4 33.2 67.3 FORMATIE VAN BRUSSEL " ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from owslib.fes2 import PropertyIsEqualTo\n", "\n", "query = PropertyIsEqualTo(propertyname='gemeente',\n", " literal='Rotselaar')\n", "df = itp.search(query=query)\n", "\n", "df.head()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Once again we can use the *pkey_interpretatie* as a permanent link to the information of these interpretations:" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "https://www.dov.vlaanderen.be/data/interpretatie/1981-217464\n" ] } ], "source": [ "for pkey_interpretatie in set(df.pkey_interpretatie):\n", " print(pkey_interpretatie)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Get 'informele hydrogeologische stratigrafie' in a bounding box based on specific properties" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "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.\n", "\n", "The following example requests the interpretations of boreholes only, within the given bounding box.\n", "\n", "(Note that the datatype of the *literal* parameter should be a string, regardless of the datatype of this field in the output dataframe.)" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[000/001] .\n", "[000/001] c\n" ] }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
pkey_interpretatiepkey_boringbetrouwbaarheid_interpretatiexystart_interpretatie_mtawdiepte_laag_vandiepte_laag_totbeschrijving
0https://www.dov.vlaanderen.be/data/interpretat...https://www.dov.vlaanderen.be/data/boring/1981...goed172148.5182587.510.940.02.5QUARTAIR
1https://www.dov.vlaanderen.be/data/interpretat...https://www.dov.vlaanderen.be/data/boring/1981...goed172148.5182587.510.942.513.6FORMATIE VAN MALDEGEM
2https://www.dov.vlaanderen.be/data/interpretat...https://www.dov.vlaanderen.be/data/boring/1981...goed172148.5182587.510.9413.625.5FORMATIE VAN MALDEGEM (Lid van Wemmel)
3https://www.dov.vlaanderen.be/data/interpretat...https://www.dov.vlaanderen.be/data/boring/1981...goed172148.5182587.510.9425.533.2FORMATIE VAN LEDE
4https://www.dov.vlaanderen.be/data/interpretat...https://www.dov.vlaanderen.be/data/boring/1981...goed172148.5182587.510.9433.267.3FORMATIE VAN BRUSSEL
\n", "
" ], "text/plain": [ " pkey_interpretatie \\\n", "0 https://www.dov.vlaanderen.be/data/interpretat... \n", "1 https://www.dov.vlaanderen.be/data/interpretat... \n", "2 https://www.dov.vlaanderen.be/data/interpretat... \n", "3 https://www.dov.vlaanderen.be/data/interpretat... \n", "4 https://www.dov.vlaanderen.be/data/interpretat... \n", "\n", " pkey_boring \\\n", "0 https://www.dov.vlaanderen.be/data/boring/1981... \n", "1 https://www.dov.vlaanderen.be/data/boring/1981... \n", "2 https://www.dov.vlaanderen.be/data/boring/1981... \n", "3 https://www.dov.vlaanderen.be/data/boring/1981... \n", "4 https://www.dov.vlaanderen.be/data/boring/1981... \n", "\n", " betrouwbaarheid_interpretatie x y start_interpretatie_mtaw \\\n", "0 goed 172148.5 182587.5 10.94 \n", "1 goed 172148.5 182587.5 10.94 \n", "2 goed 172148.5 182587.5 10.94 \n", "3 goed 172148.5 182587.5 10.94 \n", "4 goed 172148.5 182587.5 10.94 \n", "\n", " diepte_laag_van diepte_laag_tot beschrijving \n", "0 0.0 2.5 QUARTAIR \n", "1 2.5 13.6 FORMATIE VAN MALDEGEM \n", "2 13.6 25.5 FORMATIE VAN MALDEGEM (Lid van Wemmel) \n", "3 25.5 33.2 FORMATIE VAN LEDE \n", "4 33.2 67.3 FORMATIE VAN BRUSSEL " ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from owslib.fes2 import PropertyIsEqualTo\n", "\n", "query = PropertyIsEqualTo(\n", " propertyname='Type_proef',\n", " literal='Boring')\n", "\n", "df = itp.search(\n", " location=Within(Box(100000, 100000, 200000, 200000, epsg=31370)),\n", " query=query\n", " )\n", "\n", "df.head()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We can look at one of the interpretations in a webbrowser using its *pkey_interpretatie*:" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "https://www.dov.vlaanderen.be/data/interpretatie/1981-217464\n" ] } ], "source": [ "for pkey_interpretatie in set(df.pkey_interpretatie):\n", " print(pkey_interpretatie)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Select 'informele hydrogeologische stratigrafie' in a municipality and return date" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We can limit the columns in the output dataframe by specifying the *return_fields* parameter in our search.\n", "\n", "In this example we query all the 'informele stratigrafie' interpretations in the community of Rotselaar and return their date:" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[000/001] .\n" ] }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
Datum
01981-01-01
\n", "
" ], "text/plain": [ " Datum\n", "0 1981-01-01" ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "query = PropertyIsEqualTo(propertyname='gemeente',\n", " literal='Rotselaar')\n", "df = itp.search(query=query,\n", " return_fields=('Datum',))\n", "df.head()" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
Datum
count1
unique1
top1981-01-01
freq1
\n", "
" ], "text/plain": [ " Datum\n", "count 1\n", "unique 1\n", "top 1981-01-01\n", "freq 1" ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.describe()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Get 'informele hydrogeologische stratigrafie' based on fields not available in the standard output dataframe" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "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.\n", "\n", "For example, make a selection of the interpretations in the municipality of Rotselaar, before 1/1/1990:" ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[000/001] .\n" ] }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
pkey_interpretatieDatum
0https://www.dov.vlaanderen.be/data/interpretat...1981-01-01
\n", "
" ], "text/plain": [ " pkey_interpretatie Datum\n", "0 https://www.dov.vlaanderen.be/data/interpretat... 1981-01-01" ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from owslib.fes2 import And, PropertyIsEqualTo, PropertyIsLessThan\n", "\n", "query = And([PropertyIsEqualTo(propertyname='gemeente',\n", " literal='Rotselaar'),\n", " PropertyIsLessThan(propertyname='Datum', \n", " literal='1990-01-01')]\n", " )\n", "df = itp.search(query=query,\n", " return_fields=('pkey_interpretatie', 'Datum'))\n", "df.head()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Get 'informele hydrogeologische stratigrafie' data, returning fields not available in the standard output dataframe" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "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:" ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[000/001] .\n" ] }, { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
pkey_interpretatiepkey_boringxystart_interpretatie_mtawgemeenteAuteursProefnummer
0https://www.dov.vlaanderen.be/data/interpretat...https://www.dov.vlaanderen.be/data/boring/1981...172148.5182587.510.94RotselaarOnbekend - Vlaamse Maatschappij voor Watervoor...B/3005-016
\n", "
" ], "text/plain": [ " pkey_interpretatie \\\n", "0 https://www.dov.vlaanderen.be/data/interpretat... \n", "\n", " pkey_boring x y \\\n", "0 https://www.dov.vlaanderen.be/data/boring/1981... 172148.5 182587.5 \n", "\n", " start_interpretatie_mtaw gemeente \\\n", "0 10.94 Rotselaar \n", "\n", " Auteurs Proefnummer \n", "0 Onbekend - Vlaamse Maatschappij voor Watervoor... B/3005-016 " ] }, "execution_count": 17, "metadata": {}, "output_type": "execute_result" } ], "source": [ "query = PropertyIsEqualTo(\n", " propertyname='gemeente',\n", " literal='Rotselaar')\n", "\n", "df = itp.search(query=query,\n", " return_fields=('pkey_interpretatie', 'pkey_boring',\n", " 'x', 'y', 'start_interpretatie_mtaw', 'gemeente', 'Auteurs', 'Proefnummer'))\n", "\n", "df.head()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Visualize results" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Using Folium, we can display the results of our search on a map." ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [], "source": [ "# import the necessary modules (not included in the requirements of pydov!)\n", "import folium\n", "from folium.plugins import MarkerCluster\n", "from pyproj import Transformer" ] }, { "cell_type": "code", "execution_count": 19, "metadata": {}, "outputs": [], "source": [ "# convert the coordinates to lat/lon for folium\n", "def convert_latlon(x1, y1):\n", " transformer = Transformer.from_crs(\"epsg:31370\", \"epsg:4326\", always_xy=True)\n", " x2,y2 = transformer.transform(x1, y1)\n", " return x2, y2\n", "\n", "df['lon'], df['lat'] = zip(*map(convert_latlon, df['x'], df['y'])) \n", "# convert to list\n", "loclist = df[['lat', 'lon']].values.tolist()" ] }, { "cell_type": "code", "execution_count": 20, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
Make this Notebook Trusted to load map: File -> Trust Notebook
" ], "text/plain": [ "" ] }, "execution_count": 20, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# initialize the Folium map on the centre of the selected locations, play with the zoom until ok\n", "fmap = folium.Map(location=[df['lat'].mean(), df['lon'].mean()], zoom_start=12)\n", "marker_cluster = MarkerCluster().add_to(fmap)\n", "for loc in range(0, len(loclist)):\n", " folium.Marker(loclist[loc], popup=df['Proefnummer'][loc]).add_to(marker_cluster)\n", "fmap\n" ] } ], "metadata": { "kernelspec": { "display_name": ".venv (3.13.5)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.13.5" } }, "nbformat": 4, "nbformat_minor": 4 }