{ "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. \\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", "Z_mTAW\n", "diepte_tot_m\n", "gemeente\n", "Auteurs\n", "Datum\n", "Opdrachten\n", "betrouwbaarheid_interpretatie\n", "Geldig_van\n", "Geldig_tot\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" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'name': 'Datum',\n", " 'definition': 'De datum waarop de informele hydrogeologische stratigrafie werd beschreven.',\n", " 'type': 'date',\n", " 'notnull': False,\n", " 'query': True,\n", " 'cost': 1}" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "fields['Datum']" ] }, { "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" ] }, { "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", "
pkey_interpretatiepkey_boringbetrouwbaarheid_interpretatiexydiepte_laag_vandiepte_laag_totbeschrijving
0https://www.dov.vlaanderen.be/data/interpretat...https://www.dov.vlaanderen.be/data/boring/1981...goed172148.5182587.50.02.5QUARTAIR
1https://www.dov.vlaanderen.be/data/interpretat...https://www.dov.vlaanderen.be/data/boring/1981...goed172148.5182587.52.513.6FORMATIE VAN MALDEGEM
2https://www.dov.vlaanderen.be/data/interpretat...https://www.dov.vlaanderen.be/data/boring/1981...goed172148.5182587.513.625.5FORMATIE VAN MALDEGEM (Lid van Wemmel)
3https://www.dov.vlaanderen.be/data/interpretat...https://www.dov.vlaanderen.be/data/boring/1981...goed172148.5182587.525.533.2FORMATIE VAN LEDE
4https://www.dov.vlaanderen.be/data/interpretat...https://www.dov.vlaanderen.be/data/boring/1981...goed172148.5182587.533.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 diepte_laag_van \\\n", "0 goed 172148.5 182587.5 0.0 \n", "1 goed 172148.5 182587.5 2.5 \n", "2 goed 172148.5 182587.5 13.6 \n", "3 goed 172148.5 182587.5 25.5 \n", "4 goed 172148.5 182587.5 33.2 \n", "\n", " diepte_laag_tot beschrijving \n", "0 2.5 QUARTAIR \n", "1 13.6 FORMATIE VAN MALDEGEM \n", "2 25.5 FORMATIE VAN MALDEGEM (Lid van Wemmel) \n", "3 33.2 FORMATIE VAN LEDE \n", "4 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)))\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.fes'], 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] 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", "
pkey_interpretatiepkey_boringbetrouwbaarheid_interpretatiexydiepte_laag_vandiepte_laag_totbeschrijving
0https://www.dov.vlaanderen.be/data/interpretat...https://www.dov.vlaanderen.be/data/boring/1981...goed172148.5182587.50.02.5QUARTAIR
1https://www.dov.vlaanderen.be/data/interpretat...https://www.dov.vlaanderen.be/data/boring/1981...goed172148.5182587.52.513.6FORMATIE VAN MALDEGEM
2https://www.dov.vlaanderen.be/data/interpretat...https://www.dov.vlaanderen.be/data/boring/1981...goed172148.5182587.513.625.5FORMATIE VAN MALDEGEM (Lid van Wemmel)
3https://www.dov.vlaanderen.be/data/interpretat...https://www.dov.vlaanderen.be/data/boring/1981...goed172148.5182587.525.533.2FORMATIE VAN LEDE
4https://www.dov.vlaanderen.be/data/interpretat...https://www.dov.vlaanderen.be/data/boring/1981...goed172148.5182587.533.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 diepte_laag_van \\\n", "0 goed 172148.5 182587.5 0.0 \n", "1 goed 172148.5 182587.5 2.5 \n", "2 goed 172148.5 182587.5 13.6 \n", "3 goed 172148.5 182587.5 25.5 \n", "4 goed 172148.5 182587.5 33.2 \n", "\n", " diepte_laag_tot beschrijving \n", "0 2.5 QUARTAIR \n", "1 13.6 FORMATIE VAN MALDEGEM \n", "2 25.5 FORMATIE VAN MALDEGEM (Lid van Wemmel) \n", "3 33.2 FORMATIE VAN LEDE \n", "4 67.3 FORMATIE VAN BRUSSEL " ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from owslib.fes 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] 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", "
pkey_interpretatiepkey_boringbetrouwbaarheid_interpretatiexydiepte_laag_vandiepte_laag_totbeschrijving
0https://www.dov.vlaanderen.be/data/interpretat...https://www.dov.vlaanderen.be/data/boring/1981...goed172148.5182587.50.02.5QUARTAIR
1https://www.dov.vlaanderen.be/data/interpretat...https://www.dov.vlaanderen.be/data/boring/1981...goed172148.5182587.52.513.6FORMATIE VAN MALDEGEM
2https://www.dov.vlaanderen.be/data/interpretat...https://www.dov.vlaanderen.be/data/boring/1981...goed172148.5182587.513.625.5FORMATIE VAN MALDEGEM (Lid van Wemmel)
3https://www.dov.vlaanderen.be/data/interpretat...https://www.dov.vlaanderen.be/data/boring/1981...goed172148.5182587.525.533.2FORMATIE VAN LEDE
4https://www.dov.vlaanderen.be/data/interpretat...https://www.dov.vlaanderen.be/data/boring/1981...goed172148.5182587.533.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 diepte_laag_van \\\n", "0 goed 172148.5 182587.5 0.0 \n", "1 goed 172148.5 182587.5 2.5 \n", "2 goed 172148.5 182587.5 13.6 \n", "3 goed 172148.5 182587.5 25.5 \n", "4 goed 172148.5 182587.5 33.2 \n", "\n", " diepte_laag_tot beschrijving \n", "0 2.5 QUARTAIR \n", "1 13.6 FORMATIE VAN MALDEGEM \n", "2 25.5 FORMATIE VAN MALDEGEM (Lid van Wemmel) \n", "3 33.2 FORMATIE VAN LEDE \n", "4 67.3 FORMATIE VAN BRUSSEL " ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from owslib.fes 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)),\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": [ { "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": [ { "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.fes 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": [ { "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_boringxyZ_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", " Z_mTAW gemeente Auteurs \\\n", "0 10.94 Rotselaar Onbekend - Vlaamse Maatschappij voor Watervoor... \n", "\n", " Proefnummer \n", "0 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', 'Z_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" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python [conda env:pydov]", "language": "python", "name": "conda-env-pydov-py" }, "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.7.6" } }, "nbformat": 4, "nbformat_minor": 4 }