{ "cells": [ { "cell_type": "markdown", "id": "3a252814", "metadata": {}, "source": [ "# Downloading surface water data\n", "This section notebook shows some how to download surface water data into a GeoDataFrame using the `nlmod` package.\n", "\n", "We select an area near around Schoonhoven for this demonstration. There are three water boards in the this area, and we download seasonal data about the stage of the surface water for each. For locations without a stage from the water board, we obtain information from a Digital Terrain Model near the surface water features, to estimate a stage. We assign a stage of 0.0 m NAP to the river Lek." ] }, { "cell_type": "code", "execution_count": null, "id": "a13eab81", "metadata": {}, "outputs": [], "source": [ "import os\n", "import rioxarray\n", "import nlmod" ] }, { "cell_type": "code", "execution_count": null, "id": "be54846a", "metadata": {}, "outputs": [], "source": [ "nlmod.util.get_color_logger(\"INFO\")\n", "nlmod.show_versions()" ] }, { "cell_type": "markdown", "id": "e10ce1e3", "metadata": {}, "source": [ "First we specify a folder where we can save downloaded data to and define the extent of our model." ] }, { "cell_type": "code", "execution_count": null, "id": "d2e50196", "metadata": {}, "outputs": [], "source": [ "model_name = \"steady\"\n", "model_ws = \"02_surface_water\"\n", "figdir, cachedir = nlmod.util.get_model_dirs(model_ws)\n", "extent = [116_500, 120_000, 439_000, 442_000]" ] }, { "cell_type": "markdown", "id": "b7c5efff", "metadata": {}, "source": [ "## AHN\n", "Download the Digital Terrain model of the Netherlands (AHN). To speed up this notebook we download data on a resolution of 5 meter. We can change this to a resolution of 0.5 meter, changing the identifier to \"AHN4_DTM_05m\"." ] }, { "cell_type": "code", "execution_count": null, "id": "a696b36a", "metadata": {}, "outputs": [], "source": [ "fname_ahn = os.path.join(cachedir, \"ahn.tif\")\n", "if not os.path.isfile(fname_ahn):\n", " ahn = nlmod.read.ahn.download_ahn4(extent)\n", " ahn.rio.to_raster(fname_ahn)\n", "ahn = rioxarray.open_rasterio(fname_ahn, mask_and_scale=True)[0]" ] }, { "cell_type": "markdown", "id": "829452bc", "metadata": {}, "source": [ "## Layer 'waterdeel' from bgt\n", "As the source of the location of the surface water bodies we use the 'waterdeel' layer of the Basisregistratie Grootschalige Topografie (BGT). This data consists of detailed polygons, maintained by dutch government agencies (water boards, municipalities and Rijkswaterstaat)." ] }, { "cell_type": "code", "execution_count": null, "id": "65eaae66", "metadata": {}, "outputs": [], "source": [ "bgt = nlmod.read.bgt.download_bgt(extent)" ] }, { "cell_type": "markdown", "id": "84913028", "metadata": {}, "source": [ "### Add minimum surface height around surface water bodies\n", "Get the minimum surface level in 5 meter around surface water levels and add these data to the column 'ahn_min'." ] }, { "cell_type": "code", "execution_count": null, "id": "77de7451", "metadata": {}, "outputs": [], "source": [ "bgt = nlmod.gwf.add_min_ahn_to_gdf(bgt, ahn, buffer=5.0, column=\"ahn_min\")" ] }, { "cell_type": "markdown", "id": "9e5aefb2", "metadata": {}, "source": [ "### Plot 'bronhouder'\n", "We can plot the column 'bronhouder' from the GeoDataFrame bgt. We see there are three water boards in this area (with codes starting with 'W')." ] }, { "cell_type": "code", "execution_count": null, "id": "dad09b8b", "metadata": {}, "outputs": [], "source": [ "f, ax = nlmod.plot.get_map(extent)\n", "bgt.plot(\"bronhouder\", legend=True, ax=ax)" ] }, { "cell_type": "markdown", "id": "c7ca3205", "metadata": {}, "source": [ "## level areas\n", "For these three waterboards we download the level areas (peilgebieden): polygons with information about winter and summer stages." ] }, { "cell_type": "code", "execution_count": null, "id": "f84940f1", "metadata": {}, "outputs": [], "source": [ "la = nlmod.gwf.surface_water.download_level_areas(\n", " bgt, extent=extent, raise_exceptions=False\n", ")" ] }, { "cell_type": "markdown", "id": "ca8b152a", "metadata": {}, "source": [ "### Plot summer stage\n", "The method download_level_areas() generates a dictionary with the name of the water boards as keys and GeoDataFrames as values. Each GeoDataFrame contains the columns summer_stage and winter_stage. Let's plot the summer stage, together with the location of the surface water bodies." ] }, { "cell_type": "code", "execution_count": null, "id": "8fc9ebac", "metadata": {}, "outputs": [], "source": [ "f, ax = nlmod.plot.get_map(extent)\n", "bgt.plot(color=\"k\", ax=ax)\n", "for wb in la:\n", " la[wb].plot(\"summer_stage\", ax=ax, vmin=-3, vmax=1, zorder=0)" ] }, { "cell_type": "markdown", "id": "27f1f547", "metadata": {}, "source": [ "### Add stages to bgt-data\n", "We then add the information from these level areas to the surface water bodies. Afterwards we can then again plot the summer-stage, but now for the individual water bodies." ] }, { "cell_type": "code", "execution_count": null, "id": "7d3012b2", "metadata": {}, "outputs": [], "source": [ "bgt = nlmod.gwf.surface_water.add_stages_from_waterboards(bgt, la=la)\n", "fig, ax = nlmod.plot.get_map(extent)\n", "bgt.plot(ax=ax, column=\"summer_stage\", legend=True);" ] }, { "cell_type": "markdown", "id": "5e5f3e46", "metadata": {}, "source": [ "## Save the data to use in other notebooks as well\n", "We save the bgt-data to a GeoPackage file, so we can use the data in other notebooks with surface water as well." ] }, { "cell_type": "code", "execution_count": null, "id": "e6a54720", "metadata": {}, "outputs": [], "source": [ "fname_bgt = os.path.join(cachedir, \"bgt.gpkg\")\n", "bgt.to_file(fname_bgt)" ] } ], "metadata": { "language_info": { "name": "python" } }, "nbformat": 4, "nbformat_minor": 5 }