{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Example of DOV search methods for interpretations (informele 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_stratigrafie.ipynb)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Use cases explained below\n", "* Get 'informele stratigrafie' in a bounding box\n", "* Get 'informele stratigrafie' with specific properties\n", "* Get 'informele stratigrafie' in a bounding box based on specific properties\n", "* Select 'informele stratigrafie' in a municipality and return date\n", "* Get 'informele stratigrafie' based on fields not available in the standard output dataframe\n", "* Get 'informele 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 stratigrafie'" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "from pydov.search.interpretaties import InformeleStratigrafieSearch\n", "itp = InformeleStratigrafieSearch()" ] }, { "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 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.'" ] }, "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 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", "Proeffiche\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", "pkey_boring\n", "pkey_sondering\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.InformeleStratigrafieSearch\n", "
\n", "

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.

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

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
\n", "
\n", " \n", " \n", "
\n", "

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:
  • \n", " \n", "
    \n", " \n", "
    \n", " pydov.util.codelists.FeatureCatalogueValues\n", "
    \n", " \n", " \n", "
    \n", "

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

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

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

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

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
\n", "
\n", " \n", " \n", "
\n", "

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
\n", "
\n", " \n", " \n", "
\n", "

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
\n", "
\n", " \n", " \n", "
\n", "

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
\n", "
\n", " \n", " \n", "
\n", "

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
\n", "
\n", " \n", " \n", "
\n", "

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
\n", "
\n", " \n", " \n", "
\n", "

gemeente - De gemeente waarin de proef 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 stratigrafie.

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

Datum - De datum waarop de informele 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 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 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 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 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 stratigrafie 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 stratigrafie 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 stratigrafie in vrije tekst (onbeperkt in lengte).

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

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
\n", "
\n", " \n", " \n", "
\n", "

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
\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 stratigrafie' in a bounding box" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Get data for all the 'informele 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", "
pkey_interpretatiepkey_boringpkey_sonderingbetrouwbaarheid_interpretatiexystart_interpretatie_mtawdiepte_laag_vandiepte_laag_totbeschrijving
0https://www.dov.vlaanderen.be/data/interpretat...https://www.dov.vlaanderen.be/data/boring/1974...NaNgoed153147.0206931.014.120.03.00Quartair
1https://www.dov.vlaanderen.be/data/interpretat...https://www.dov.vlaanderen.be/data/boring/1974...NaNgoed153147.0206931.014.123.014.05Tertiair - Mioceen: Antwerpiaan
\n", "
" ], "text/plain": [ " pkey_interpretatie \\\n", "0 https://www.dov.vlaanderen.be/data/interpretat... \n", "1 https://www.dov.vlaanderen.be/data/interpretat... \n", "\n", " pkey_boring pkey_sondering \\\n", "0 https://www.dov.vlaanderen.be/data/boring/1974... NaN \n", "1 https://www.dov.vlaanderen.be/data/boring/1974... NaN \n", "\n", " betrouwbaarheid_interpretatie x y start_interpretatie_mtaw \\\n", "0 goed 153147.0 206931.0 14.12 \n", "1 goed 153147.0 206931.0 14.12 \n", "\n", " diepte_laag_van diepte_laag_tot beschrijving \n", "0 0.0 3.00 Quartair \n", "1 3.0 14.05 Tertiair - Mioceen: Antwerpiaan " ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from pydov.util.location import Within, Box\n", "\n", "df = itp.search(location=Within(Box(153145, 206930, 153150, 206935, 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/1975-213484\n" ] } ], "source": [ "for pkey_interpretatie in set(df.pkey_interpretatie):\n", " print(pkey_interpretatie)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Get 'informele 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 'InformeleStratigrafie' 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/003] ...\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", "
pkey_interpretatiepkey_boringpkey_sonderingbetrouwbaarheid_interpretatiexystart_interpretatie_mtawdiepte_laag_vandiepte_laag_totbeschrijving
0https://www.dov.vlaanderen.be/data/interpretat...https://www.dov.vlaanderen.be/data/boring/2016...NaNgoed224687.4158191.0124.00.003.75q2
1https://www.dov.vlaanderen.be/data/interpretat...https://www.dov.vlaanderen.be/data/boring/2016...NaNgoed224687.4158191.0124.03.756.00q1c
2https://www.dov.vlaanderen.be/data/interpretat...https://www.dov.vlaanderen.be/data/boring/1993...NaNgoed224820.0157794.0132.00.0050.00?
3https://www.dov.vlaanderen.be/data/interpretat...https://www.dov.vlaanderen.be/data/boring/1993...NaNgoed224820.0157794.0132.05.0050.00Formatie van Gulpen
\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", "\n", " pkey_boring pkey_sondering \\\n", "0 https://www.dov.vlaanderen.be/data/boring/2016... NaN \n", "1 https://www.dov.vlaanderen.be/data/boring/2016... NaN \n", "2 https://www.dov.vlaanderen.be/data/boring/1993... NaN \n", "3 https://www.dov.vlaanderen.be/data/boring/1993... NaN \n", "\n", " betrouwbaarheid_interpretatie x y start_interpretatie_mtaw \\\n", "0 goed 224687.4 158191.0 124.0 \n", "1 goed 224687.4 158191.0 124.0 \n", "2 goed 224820.0 157794.0 132.0 \n", "3 goed 224820.0 157794.0 132.0 \n", "\n", " diepte_laag_van diepte_laag_tot beschrijving \n", "0 0.00 3.75 q2 \n", "1 3.75 6.00 q1c \n", "2 0.00 50.00 ? \n", "3 5.00 50.00 Formatie van Gulpen " ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from owslib.fes2 import PropertyIsEqualTo\n", "\n", "query = PropertyIsEqualTo(propertyname='gemeente',\n", " literal='Herstappe')\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/1993-097697\n", "https://www.dov.vlaanderen.be/data/interpretatie/2010-106477\n", "https://www.dov.vlaanderen.be/data/interpretatie/2016-271517\n" ] } ], "source": [ "for pkey_interpretatie in set(df.pkey_interpretatie):\n", " print(pkey_interpretatie)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Get 'informele 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/003] ...\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", "
pkey_interpretatiepkey_boringpkey_sonderingbetrouwbaarheid_interpretatiexystart_interpretatie_mtawdiepte_laag_vandiepte_laag_totbeschrijving
0https://www.dov.vlaanderen.be/data/interpretat...https://www.dov.vlaanderen.be/data/boring/1896...NaNgoed205952.9205993.033.000.01.0R
1https://www.dov.vlaanderen.be/data/interpretat...https://www.dov.vlaanderen.be/data/boring/1896...NaNgoed205952.9205993.033.001.02.3q4
2https://www.dov.vlaanderen.be/data/interpretat...https://www.dov.vlaanderen.be/data/boring/1896...NaNgoed205970.0205270.534.000.02.3q4
3https://www.dov.vlaanderen.be/data/interpretat...https://www.dov.vlaanderen.be/data/boring/1975...NaNgoed205264.2205607.533.380.08.0Kwartair
\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", "\n", " pkey_boring pkey_sondering \\\n", "0 https://www.dov.vlaanderen.be/data/boring/1896... NaN \n", "1 https://www.dov.vlaanderen.be/data/boring/1896... NaN \n", "2 https://www.dov.vlaanderen.be/data/boring/1896... NaN \n", "3 https://www.dov.vlaanderen.be/data/boring/1975... NaN \n", "\n", " betrouwbaarheid_interpretatie x y start_interpretatie_mtaw \\\n", "0 goed 205952.9 205993.0 33.00 \n", "1 goed 205952.9 205993.0 33.00 \n", "2 goed 205970.0 205270.5 34.00 \n", "3 goed 205264.2 205607.5 33.38 \n", "\n", " diepte_laag_van diepte_laag_tot beschrijving \n", "0 0.0 1.0 R \n", "1 1.0 2.3 q4 \n", "2 0.0 2.3 q4 \n", "3 0.0 8.0 Kwartair " ] }, "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(205000, 205000, 206000, 206000, 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/1896-044150\n", "https://www.dov.vlaanderen.be/data/interpretatie/1975-044576\n", "https://www.dov.vlaanderen.be/data/interpretatie/1896-044149\n" ] } ], "source": [ "for pkey_interpretatie in set(df.pkey_interpretatie):\n", " print(pkey_interpretatie)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Select 'informele 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 city of Ghent and return their date:" ] }, { "cell_type": "code", "execution_count": 15, "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", " \n", " \n", "
Datum
01991-02-28
11991-03-01
21991-03-05
31991-03-06
41991-03-12
\n", "
" ], "text/plain": [ " Datum\n", "0 1991-02-28\n", "1 1991-03-01\n", "2 1991-03-05\n", "3 1991-03-06\n", "4 1991-03-12" ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from owslib.fes2 import And, Not, PropertyIsNull\n", "\n", "query = And([\n", " PropertyIsEqualTo(propertyname='gemeente',\n", " literal='Gent'),\n", " Not([PropertyIsNull('Datum')])\n", "])\n", "\n", "df = itp.search(query=query,\n", " return_fields=('Datum',))\n", "df.head()" ] }, { "cell_type": "code", "execution_count": 16, "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
count560
unique245
top1996-11-25
freq41
\n", "
" ], "text/plain": [ " Datum\n", "count 560\n", "unique 245\n", "top 1996-11-25\n", "freq 41" ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.describe()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Get 'informele 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 municipality the of Antwerp, before 1/1/1900:" ] }, { "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", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
pkey_interpretatieDatum
0https://www.dov.vlaanderen.be/data/interpretat...1895-05-21
1https://www.dov.vlaanderen.be/data/interpretat...1895-05-21
2https://www.dov.vlaanderen.be/data/interpretat...1895-05-21
3https://www.dov.vlaanderen.be/data/interpretat...1895-05-21
4https://www.dov.vlaanderen.be/data/interpretat...1895-05-21
\n", "
" ], "text/plain": [ " pkey_interpretatie Datum\n", "0 https://www.dov.vlaanderen.be/data/interpretat... 1895-05-21\n", "1 https://www.dov.vlaanderen.be/data/interpretat... 1895-05-21\n", "2 https://www.dov.vlaanderen.be/data/interpretat... 1895-05-21\n", "3 https://www.dov.vlaanderen.be/data/interpretat... 1895-05-21\n", "4 https://www.dov.vlaanderen.be/data/interpretat... 1895-05-21" ] }, "execution_count": 17, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from owslib.fes2 import And, PropertyIsEqualTo, PropertyIsLessThan\n", "\n", "query = And([PropertyIsEqualTo(propertyname='gemeente',\n", " literal='Antwerpen'),\n", " PropertyIsLessThan(propertyname='Datum', \n", " literal='1900-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 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": 18, "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", " \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_boringpkey_sonderingxystart_interpretatie_mtawgemeenteAuteursProefnummer
0https://www.dov.vlaanderen.be/data/interpretat...https://www.dov.vlaanderen.be/data/boring/2016...NaN224687.4158191.0124.0HerstappeRutot, A. - Belgische Geologische Dienst (BGD)kb33d106e-B236
1https://www.dov.vlaanderen.be/data/interpretat...https://www.dov.vlaanderen.be/data/boring/1993...NaN224820.0157794.0132.0HerstappeBoormeester, - bedrijf-dienst onbekendkb41d120e-B1027
2https://www.dov.vlaanderen.be/data/interpretat...https://www.dov.vlaanderen.be/data/boring/1993...NaN224820.0157794.0132.0HerstappeLagrou, David - VLAKOkb41d120e-B1027
\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", "\n", " pkey_boring pkey_sondering \\\n", "0 https://www.dov.vlaanderen.be/data/boring/2016... NaN \n", "1 https://www.dov.vlaanderen.be/data/boring/1993... NaN \n", "2 https://www.dov.vlaanderen.be/data/boring/1993... NaN \n", "\n", " x y start_interpretatie_mtaw gemeente \\\n", "0 224687.4 158191.0 124.0 Herstappe \n", "1 224820.0 157794.0 132.0 Herstappe \n", "2 224820.0 157794.0 132.0 Herstappe \n", "\n", " Auteurs Proefnummer \n", "0 Rutot, A. - Belgische Geologische Dienst (BGD) kb33d106e-B236 \n", "1 Boormeester, - bedrijf-dienst onbekend kb41d120e-B1027 \n", "2 Lagrou, David - VLAKO kb41d120e-B1027 " ] }, "execution_count": 18, "metadata": {}, "output_type": "execute_result" } ], "source": [ "query = PropertyIsEqualTo(\n", " propertyname='gemeente',\n", " literal='Herstappe')\n", "\n", "df = itp.search(query=query,\n", " return_fields=('pkey_interpretatie', 'pkey_boring', 'pkey_sondering',\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": 19, "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": 20, "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": 21, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
Make this Notebook Trusted to load map: File -> Trust Notebook
" ], "text/plain": [ "" ] }, "execution_count": 21, "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 }