{ "cells": [ { "cell_type": "markdown", "id": "b809a35c-62b1-4fef-b69d-a00417343a94", "metadata": {}, "source": [ "## Accessing Deltares global flood data\n", "\n", "[Deltares](https://www.deltares.nl/en/) has produced a series of global inundation maps of flood depth using a geographic information systems (GIS)-based inundation model that takes into account water level attenuation and is forced by sea level. Multiple datasets were created using various digital elevation models (DEMs) at multiple resolutions under two different sea level rise (SLR) conditions: current (2018) and 2050. \n", "\n", "This dataset is stored in the West Europe Azure region, so this notebook will run most efficiently on Azure compute located in the same region. If you are using this data for environmental science applications, consider applying for an AI for Earth grant to support your compute requirements." ] }, { "cell_type": "markdown", "id": "f215a7ef-bdd5-497e-b9bb-53621ef8169c", "metadata": {}, "source": [ "### Environment setup" ] }, { "cell_type": "code", "execution_count": 1, "id": "30185f5a-50e3-4c9d-8644-1cb8b48aadde", "metadata": {}, "outputs": [], "source": [ "import math\n", "import os\n", "import warnings\n", "\n", "import matplotlib.pyplot as plt\n", "import numpy as np\n", "import xarray as xr\n", "\n", "import dask.distributed\n", "import pystac_client\n", "import planetary_computer\n", "import rioxarray # noqa: F401\n", "import contextily\n", "import shapely.geometry\n", "import cartopy.feature as cfeature\n", "import cartopy.crs as ccrs" ] }, { "cell_type": "markdown", "id": "13218229-f4ec-4d8f-8915-112ddcd6df4c", "metadata": {}, "source": [ "### Create a local Dask cluster\n", "\n", "Enable parallel reads and processing of data using Dask and xarray." ] }, { "cell_type": "code", "execution_count": 2, "id": "c2328949-b3dc-4dc9-abfa-c643ec7fbcbb", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "http://192.168.1.84:8787/status\n" ] } ], "source": [ "client = dask.distributed.Client(processes=False)\n", "print(client.dashboard_link)" ] }, { "cell_type": "markdown", "id": "661a2ac9-2281-42d7-b289-d17c662c9047", "metadata": {}, "source": [ "### Data access\n", "\n", "The entire dataset is made up of several dozen individual netCDF files, each representing an entire global inundation map, but derived from either a different source DEM, sea level rise condition, or return period. Return periods are occurrence probabilities for floods of a particular magnitude, often referred to as, for example, \"a 100 year flood\". Use the STAC API to query on these various properties:\n", "\n", "To start, we'll load and plot the inundation data produced from the 90m NASADEM at a 100 year return period for 2050 sea level rise conditions. " ] }, { "cell_type": "code", "execution_count": 3, "id": "f5a73cc7-1635-4cc8-bb5e-5ad4fc5c47bd", "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "\n", "\n", "
<xarray.Dataset> Size: 373GB\n", "Dimensions: (time: 1, lat: 216000, lon: 432000)\n", "Coordinates:\n", " * lat (lat) float64 2MB -90.0 -90.0 -90.0 -90.0 ... 90.0 90.0 90.0\n", " * lon (lon) float64 3MB -180.0 -180.0 -180.0 ... 180.0 180.0 180.0\n", " * time (time) datetime64[ns] 8B 2010-01-01\n", "Data variables:\n", " inun (time, lat, lon) float32 373GB dask.array<chunksize=(1, 600, 600), meta=np.ndarray>\n", " projection object 8B ...\n", "Attributes:\n", " Conventions: CF-1.6\n", " config_file: /mnt/globalRuns/watermask_post_NASA90m_rest/run_rp0010_slr2...\n", " institution: Deltares\n", " project: Microsoft Planetary Computer - Global Flood Maps\n", " references: https://www.deltares.nl/en/\n", " source: Global Tide and Surge Model v3.0 - ERA5\n", " title: GFM - NASA DEM 90m - 2050 slr - 0010-year return level
<xarray.Dataset> Size: 48MB\n", "Dimensions: (time: 1, lat: 3303, lon: 3632)\n", "Coordinates:\n", " * lat (lat) float64 26kB 15.62 15.62 15.62 15.62 ... 18.37 18.37 18.37\n", " * lon (lon) float64 29kB 93.94 93.94 93.94 93.94 ... 96.96 96.96 96.96\n", " * time (time) datetime64[ns] 8B 2010-01-01\n", "Data variables:\n", " inun (time, lat, lon) float32 48MB dask.array<chunksize=(1, 458, 73), meta=np.ndarray>\n", " projection object 8B ...\n", "Attributes:\n", " Conventions: CF-1.6\n", " config_file: /mnt/globalRuns/watermask_post_NASA90m_rest/run_rp0010_slr2...\n", " institution: Deltares\n", " project: Microsoft Planetary Computer - Global Flood Maps\n", " references: https://www.deltares.nl/en/\n", " source: Global Tide and Surge Model v3.0 - ERA5\n", " title: GFM - NASA DEM 90m - 2050 slr - 0010-year return level
<xarray.Dataset> Size: 96MB\n", "Dimensions: (time: 2, lat: 3303, lon: 3632)\n", "Coordinates:\n", " * lat (lat) float64 26kB 15.62 15.62 15.62 15.62 ... 18.37 18.37 18.37\n", " * lon (lon) float64 29kB 93.94 93.94 93.94 93.94 ... 96.96 96.96 96.96\n", " * time (time) datetime64[ns] 16B 2018-01-01 2050-01-01\n", "Data variables:\n", " inun (time, lat, lon) float32 96MB dask.array<chunksize=(1, 458, 73), meta=np.ndarray>\n", " projection (time) object 16B nan nan\n", "Attributes:\n", " Conventions: CF-1.6\n", " config_file: /mnt/globalRuns/watermask_post_NASA/run_rp0010_slr2018/coas...\n", " institution: Deltares\n", " project: Microsoft Planetary Computer - Global Flood Maps\n", " references: https://www.deltares.nl/en/\n", " source: Global Tide and Surge Model v3.0 - ERA5\n", " title: GFM - NASA DEM 90m - 2018 slr - 0010-year return level