Skip to content

Commit 8a34f53

Browse files
committed
Update data access for deltares-floods from planetary computer
Following the changes in microsoft/PlanetaryComputerExamples#301. The adlfs package is now required for data access and has been added to the environment.
1 parent 6f55f28 commit 8a34f53

2 files changed

Lines changed: 19 additions & 8 deletions

File tree

01_Coastal_flooding/Hazard_assessment_FLOOD_COASTAL_floodmaps.ipynb

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -117,21 +117,23 @@
117117
"`````{admonition} Find more info about the libraries used in this workflow here\n",
118118
":class: hint dropdown\n",
119119
"In this notebook, we will use the following Python libraries:\n",
120+
"\n",
120121
"- [os](https://docs.python.org/3/library/os.html) - Provides a way to interact with the operating system, allowing the creation of directories and file manipulation.\n",
122+
"- [urllib.parse](https://docs.python.org/3/library/urllib.parse.html) - URL operations.\n",
121123
"- [numpy](https://numpy.org/) - A powerful library for numerical computations in Python, widely used for array operations and mathematical functions.\n",
122124
"- [pandas](https://pandas.pydata.org/) - A data manipulation and analysis library, essential for working with structured data in tabular form.\n",
123125
"- [rasterio](https://rasterio.readthedocs.io/en/stable/) - A library for reading and writing geospatial raster data, providing functionalities to explore and manipulate raster datasets.\n",
124126
"- [xarray](https://docs.xarray.dev/en/stable/) - library for working with labelled multi-dimensional arrays.\n",
125127
"- [rioxarray](https://corteva.github.io/rioxarray/stable/) - An extension of the xarray library that simplifies working with geospatial raster data in GeoTIFF format.\n",
126128
"- [damagescanner](https://damagescanner.readthedocs.io/en/latest/#) - A library designed for calculating flood damages based on geospatial data, particularly suited for analyzing flood impact.\n",
127129
"- [matplotlib](https://matplotlib.org/) - A versatile plotting library in Python, commonly used for creating static, animated, and interactive visualizations.\n",
128-
"- [contextily](https://contextily.readthedocs.io/en/latest/) A library for adding basemaps to plots, enhancing geospatial visualizations.\n",
129-
"- [cartopy](https://scitools.org.uk/cartopy/docs/latest/) A library for geospatial data processing.\n",
130-
"\n",
131-
"- [planetary-computer](https://pypi.org/project/planetary-computer/) A library for interacting with the Microsoft Planetary Computer.\n",
132-
"- [dask](https://www.dask.org/) A library for parallel computing and task scheduling.\n",
133-
"- [pystac-client](https://pystac-client.readthedocs.io/en/stable/) A library for for working with STAC Catalogs and APIs.\n",
134-
"- [shapely](https://shapely.readthedocs.io/en/stable/index.html) A library for manipulation and analysis of geometric objects.\n",
130+
"- [contextily](https://contextily.readthedocs.io/en/latest/) - A library for adding basemaps to plots, enhancing geospatial visualizations.\n",
131+
"- [cartopy](https://scitools.org.uk/cartopy/docs/latest/) - A library for geospatial data processing.\n",
132+
"- [planetary-computer](https://pypi.org/project/planetary-computer/) - A library for interacting with the Microsoft Planetary Computer.\n",
133+
"- [dask](https://www.dask.org/) - A library for parallel computing and task scheduling.\n",
134+
"- [pystac-client](https://pystac-client.readthedocs.io/en/stable/) - A library for for working with STAC Catalogs and APIs.\n",
135+
"- [adlfs](https://github.com/fsspec/adlfs) - Interface to access data from Azure-Datalake storage.\n",
136+
"- [shapely](https://shapely.readthedocs.io/en/stable/index.html) - A library for manipulation and analysis of geometric objects.\n",
135137
"\n",
136138
"These libraries collectively enable the download, processing, analysis, and visualization of geospatial and numerical data.\n",
137139
"`````"
@@ -146,6 +148,7 @@
146148
"source": [
147149
"# Packages for downloading data and managing files\n",
148150
"import os\n",
151+
"import urllib\n",
149152
"import pystac_client\n",
150153
"import planetary_computer\n",
151154
"\n",
@@ -302,9 +305,16 @@
302305
"metadata": {},
303306
"outputs": [],
304307
"source": [
305-
"# select first item from the search and open the dataset \n",
308+
"# select the first item from the search and open the dataset \n",
306309
"item = next(search.items())\n",
307310
"url = item.assets[\"index\"].href\n",
311+
"\n",
312+
"# environment variables with authentication information for the data access\n",
313+
"token = urllib.parse.urlparse(planetary_computer.sign_url(url)).query\n",
314+
"os.environ[\"AZURE_STORAGE_SAS_TOKEN\"] = token\n",
315+
"os.environ[\"AZURE_STORAGE_ANON\"] = \"false\"\n",
316+
"os.environ[\"AZURE_STORAGE_ACCOUNT_NAME\"] = \"deltaresfloodssa\"\n",
317+
"\n",
308318
"ds = xr.open_dataset(f\"reference::{url}\", engine=\"zarr\", consolidated=False, chunks={})"
309319
]
310320
},

environment.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ channels:
44
- conda-forge
55

66
dependencies:
7+
- adlfs=2024.7.0
78
- aiohttp=3.9.5
89
- cartopy=0.23.0
910
- cdsapi=0.7.0

0 commit comments

Comments
 (0)