{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Example of DOV search methods for interpretations (informele stratigrafie)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"[](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",
"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",
"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"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'name': 'Datum',\n",
" 'definition': 'De datum waarop de informele 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 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"
]
},
{
"data": {
"text/html": [
"
\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" pkey_interpretatie | \n",
" pkey_boring | \n",
" pkey_sondering | \n",
" betrouwbaarheid_interpretatie | \n",
" x | \n",
" y | \n",
" diepte_laag_van | \n",
" diepte_laag_tot | \n",
" beschrijving | \n",
"
\n",
" \n",
" \n",
" \n",
" | 0 | \n",
" https://www.dov.vlaanderen.be/data/interpretat... | \n",
" https://www.dov.vlaanderen.be/data/boring/1974... | \n",
" NaN | \n",
" goed | \n",
" 153147.0 | \n",
" 206931.0 | \n",
" 0.0 | \n",
" 3.00 | \n",
" Quartair | \n",
"
\n",
" \n",
" | 1 | \n",
" https://www.dov.vlaanderen.be/data/interpretat... | \n",
" https://www.dov.vlaanderen.be/data/boring/1974... | \n",
" NaN | \n",
" goed | \n",
" 153147.0 | \n",
" 206931.0 | \n",
" 3.0 | \n",
" 14.05 | \n",
" Tertiair - Mioceen: Antwerpiaan | \n",
"
\n",
" \n",
"
\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 diepte_laag_van \\\n",
"0 goed 153147.0 206931.0 0.0 \n",
"1 goed 153147.0 206931.0 3.0 \n",
"\n",
" diepte_laag_tot beschrijving \n",
"0 3.00 Quartair \n",
"1 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)))\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.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/003] ...\n"
]
},
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" pkey_interpretatie | \n",
" pkey_boring | \n",
" pkey_sondering | \n",
" betrouwbaarheid_interpretatie | \n",
" x | \n",
" y | \n",
" diepte_laag_van | \n",
" diepte_laag_tot | \n",
" beschrijving | \n",
"
\n",
" \n",
" \n",
" \n",
" | 0 | \n",
" https://www.dov.vlaanderen.be/data/interpretat... | \n",
" https://www.dov.vlaanderen.be/data/boring/2016... | \n",
" NaN | \n",
" goed | \n",
" 224687.4 | \n",
" 158191.0 | \n",
" 0.00 | \n",
" 3.75 | \n",
" q2 | \n",
"
\n",
" \n",
" | 1 | \n",
" https://www.dov.vlaanderen.be/data/interpretat... | \n",
" https://www.dov.vlaanderen.be/data/boring/2016... | \n",
" NaN | \n",
" goed | \n",
" 224687.4 | \n",
" 158191.0 | \n",
" 3.75 | \n",
" 6.00 | \n",
" q1c | \n",
"
\n",
" \n",
" | 2 | \n",
" https://www.dov.vlaanderen.be/data/interpretat... | \n",
" https://www.dov.vlaanderen.be/data/boring/1993... | \n",
" NaN | \n",
" goed | \n",
" 224820.0 | \n",
" 157794.0 | \n",
" 0.00 | \n",
" 50.00 | \n",
" ? | \n",
"
\n",
" \n",
" | 3 | \n",
" https://www.dov.vlaanderen.be/data/interpretat... | \n",
" https://www.dov.vlaanderen.be/data/boring/1993... | \n",
" NaN | \n",
" goed | \n",
" 224820.0 | \n",
" 157794.0 | \n",
" 5.00 | \n",
" 50.00 | \n",
" Formatie van Gulpen | \n",
"
\n",
" \n",
"
\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 diepte_laag_van \\\n",
"0 goed 224687.4 158191.0 0.00 \n",
"1 goed 224687.4 158191.0 3.75 \n",
"2 goed 224820.0 157794.0 0.00 \n",
"3 goed 224820.0 157794.0 5.00 \n",
"\n",
" diepte_laag_tot beschrijving \n",
"0 3.75 q2 \n",
"1 6.00 q1c \n",
"2 50.00 ? \n",
"3 50.00 Formatie van Gulpen "
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from owslib.fes 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/2010-106477\n",
"https://www.dov.vlaanderen.be/data/interpretatie/2016-271517\n",
"https://www.dov.vlaanderen.be/data/interpretatie/1993-097697\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/003] ...\n"
]
},
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" pkey_interpretatie | \n",
" pkey_boring | \n",
" pkey_sondering | \n",
" betrouwbaarheid_interpretatie | \n",
" x | \n",
" y | \n",
" diepte_laag_van | \n",
" diepte_laag_tot | \n",
" beschrijving | \n",
"
\n",
" \n",
" \n",
" \n",
" | 0 | \n",
" https://www.dov.vlaanderen.be/data/interpretat... | \n",
" https://www.dov.vlaanderen.be/data/boring/1975... | \n",
" NaN | \n",
" goed | \n",
" 205264.2 | \n",
" 205607.5 | \n",
" 0.0 | \n",
" 8.0 | \n",
" Kwartair | \n",
"
\n",
" \n",
" | 1 | \n",
" https://www.dov.vlaanderen.be/data/interpretat... | \n",
" https://www.dov.vlaanderen.be/data/boring/1896... | \n",
" NaN | \n",
" goed | \n",
" 205970.0 | \n",
" 205270.5 | \n",
" 0.0 | \n",
" 2.3 | \n",
" q4 | \n",
"
\n",
" \n",
" | 2 | \n",
" https://www.dov.vlaanderen.be/data/interpretat... | \n",
" https://www.dov.vlaanderen.be/data/boring/1896... | \n",
" NaN | \n",
" goed | \n",
" 205952.9 | \n",
" 205993.0 | \n",
" 0.0 | \n",
" 1.0 | \n",
" R | \n",
"
\n",
" \n",
" | 3 | \n",
" https://www.dov.vlaanderen.be/data/interpretat... | \n",
" https://www.dov.vlaanderen.be/data/boring/1896... | \n",
" NaN | \n",
" goed | \n",
" 205952.9 | \n",
" 205993.0 | \n",
" 1.0 | \n",
" 2.3 | \n",
" q4 | \n",
"
\n",
" \n",
"
\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/1975... 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/1896... NaN \n",
"\n",
" betrouwbaarheid_interpretatie x y diepte_laag_van \\\n",
"0 goed 205264.2 205607.5 0.0 \n",
"1 goed 205970.0 205270.5 0.0 \n",
"2 goed 205952.9 205993.0 0.0 \n",
"3 goed 205952.9 205993.0 1.0 \n",
"\n",
" diepte_laag_tot beschrijving \n",
"0 8.0 Kwartair \n",
"1 2.3 q4 \n",
"2 1.0 R \n",
"3 2.3 q4 "
]
},
"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(205000, 205000, 206000, 206000)),\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": 14,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" Datum | \n",
"
\n",
" \n",
" \n",
" \n",
" | 0 | \n",
" NaN | \n",
"
\n",
" \n",
" | 1 | \n",
" NaN | \n",
"
\n",
" \n",
" | 2 | \n",
" NaN | \n",
"
\n",
" \n",
" | 3 | \n",
" 1981-02-25 | \n",
"
\n",
" \n",
" | 4 | \n",
" NaN | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" Datum\n",
"0 NaN\n",
"1 NaN\n",
"2 NaN\n",
"3 1981-02-25\n",
"4 NaN"
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"query = PropertyIsEqualTo(propertyname='gemeente',\n",
" literal='Gent')\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",
" Datum | \n",
"
\n",
" \n",
" \n",
" \n",
" | count | \n",
" 642 | \n",
"
\n",
" \n",
" | unique | \n",
" 248 | \n",
"
\n",
" \n",
" | top | \n",
" 1996-11-25 | \n",
"
\n",
" \n",
" | freq | \n",
" 41 | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" Datum\n",
"count 642\n",
"unique 248\n",
"top 1996-11-25\n",
"freq 41"
]
},
"execution_count": 15,
"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": 16,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" pkey_interpretatie | \n",
" Datum | \n",
"
\n",
" \n",
" \n",
" \n",
" | 0 | \n",
" https://www.dov.vlaanderen.be/data/interpretat... | \n",
" 1895-05-06 | \n",
"
\n",
" \n",
" | 1 | \n",
" https://www.dov.vlaanderen.be/data/interpretat... | \n",
" 1895-05-10 | \n",
"
\n",
" \n",
" | 2 | \n",
" https://www.dov.vlaanderen.be/data/interpretat... | \n",
" 1879-08-09 | \n",
"
\n",
" \n",
" | 3 | \n",
" https://www.dov.vlaanderen.be/data/interpretat... | \n",
" 1879-08-18 | \n",
"
\n",
" \n",
" | 4 | \n",
" https://www.dov.vlaanderen.be/data/interpretat... | \n",
" 1879-03-05 | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" pkey_interpretatie Datum\n",
"0 https://www.dov.vlaanderen.be/data/interpretat... 1895-05-06\n",
"1 https://www.dov.vlaanderen.be/data/interpretat... 1895-05-10\n",
"2 https://www.dov.vlaanderen.be/data/interpretat... 1879-08-09\n",
"3 https://www.dov.vlaanderen.be/data/interpretat... 1879-08-18\n",
"4 https://www.dov.vlaanderen.be/data/interpretat... 1879-03-05"
]
},
"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='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": 17,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" pkey_interpretatie | \n",
" pkey_boring | \n",
" pkey_sondering | \n",
" x | \n",
" y | \n",
" Z_mTAW | \n",
" gemeente | \n",
" Auteurs | \n",
" Proefnummer | \n",
"
\n",
" \n",
" \n",
" \n",
" | 0 | \n",
" https://www.dov.vlaanderen.be/data/interpretat... | \n",
" https://www.dov.vlaanderen.be/data/boring/2016... | \n",
" NaN | \n",
" 224687.4 | \n",
" 158191.0 | \n",
" 124.0 | \n",
" Herstappe | \n",
" Rutôt, A. - Belgische Geologische Dienst (BGD) | \n",
" kb33d106e-B236 | \n",
"
\n",
" \n",
" | 1 | \n",
" https://www.dov.vlaanderen.be/data/interpretat... | \n",
" https://www.dov.vlaanderen.be/data/boring/1993... | \n",
" NaN | \n",
" 224820.0 | \n",
" 157794.0 | \n",
" 132.0 | \n",
" Herstappe | \n",
" boormeester - bedrijf-dienst onbekend | \n",
" kb41d120e-B1027 | \n",
"
\n",
" \n",
" | 2 | \n",
" https://www.dov.vlaanderen.be/data/interpretat... | \n",
" https://www.dov.vlaanderen.be/data/boring/1993... | \n",
" NaN | \n",
" 224820.0 | \n",
" 157794.0 | \n",
" 132.0 | \n",
" Herstappe | \n",
" Lagrou, David - VLAKO | \n",
" kb41d120e-B1027 | \n",
"
\n",
" \n",
"
\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 Z_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 Rutôt, A. - Belgische Geologische Dienst (BGD) kb33d106e-B236 \n",
"1 boormeester - bedrijf-dienst onbekend kb41d120e-B1027 \n",
"2 Lagrou, David - VLAKO kb41d120e-B1027 "
]
},
"execution_count": 17,
"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', '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": 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": "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
}