-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* correct syntax datetime.utc * Changes to incorporate geoserver in collection Also put stac_io to default from pystac as in CoCliCo Note, geoserver link is still a dummy.. Cannot fix it yet (will be soon) * rm storage account * add cog media type * forgiveness when testing if collection exists * example for reading deltadtm data * add storage account name * deltadtm v1.1 * fix --------- Co-authored-by: floriscalkoen <[email protected]> Co-authored-by: EtienneKras <[email protected]>
- Loading branch information
1 parent
477fc7e
commit c001877
Showing
5 changed files
with
215 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
AZURE_STORAGE_SAS_TOKEN="paste-your-sas-token-here" | ||
CLIENT_AZURE_STORAGE_CONNECTION_STRING="paste-your-connection-string-here" | ||
AZURE_STORAGE_SAS_TOKEN="paste-your-sas-token-here" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,187 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"id": "0", | ||
"metadata": {}, | ||
"source": [ | ||
"# DeltaDTM\n", | ||
"\n", | ||
"A global coastal digital terrain model, based on CopernicusDEM, ESA WorldCover, ICESat-2 and GEDI data. For more information, see [Pronk et al. (2024)](https://www.nature.com/articles/s41597-024-03091-9) DeltaDTM: A global coastal digital terrain model. " | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "1", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import geopandas as gpd\n", | ||
"import hvplot.xarray\n", | ||
"import pystac\n", | ||
"import rioxarray\n", | ||
"import shapely\n", | ||
"import xarray as xr\n", | ||
"from ipyleaflet import Map, basemaps\n", | ||
"\n", | ||
"storage_options = {\"account_name\": \"coclico\"}" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "2", | ||
"metadata": {}, | ||
"source": [ | ||
"## Read a snapshot with the spatial extents of all tiles\n", | ||
"\n", | ||
"Connect to the CoCliCo STAC and read the spatial extents using stac-geoparquet." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "3", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from coastpy.io.utils import read_items_extent\n", | ||
"\n", | ||
"coclico_catalog = pystac.Catalog.from_file(\n", | ||
" \"https://coclico.blob.core.windows.net/stac/v1/catalog.json\"\n", | ||
")\n", | ||
"\n", | ||
"ddtm_collection = coclico_catalog.get_child(\"deltares-delta-dtm\")\n", | ||
"ddtm_extents = read_items_extent(\n", | ||
" ddtm_collection, columns=[\"geometry\", \"assets\", \"href\"]\n", | ||
")\n", | ||
"\n", | ||
"ddtm_extents.head()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "4", | ||
"metadata": {}, | ||
"source": [ | ||
"## Zoom to your area of interest" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "5", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"m = Map(basemap=basemaps.Esri.WorldImagery, scroll_wheel_zoom=True)\n", | ||
"m.center = 15.827, -95.96\n", | ||
"m.zoom = 15\n", | ||
"m.layout.height = \"800px\"\n", | ||
"m" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "6", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"west, south, east, north = m.west, m.south, m.east, m.north\n", | ||
"# Note: small little hack to ensure the notebook also works when running all cells at once\n", | ||
"if not west:\n", | ||
" west, south, east, north = (\n", | ||
" 30.28415679931641,\n", | ||
" 31.276790311057272,\n", | ||
" 30.630912780761722,\n", | ||
" 31.51123970051334,\n", | ||
" )\n", | ||
"roi = gpd.GeoDataFrame(\n", | ||
" geometry=[shapely.geometry.box(west, south, east, north)], crs=4326\n", | ||
")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "7", | ||
"metadata": {}, | ||
"source": [ | ||
"## Find the tiles for your region of interest" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "8", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from coastpy.io.cloud import to_https_url\n", | ||
"\n", | ||
"hrefs = gpd.sjoin(ddtm_extents, roi).href.to_list()\n", | ||
"href = hrefs[0]\n", | ||
"href = to_https_url(href, storage_options={\"account_name\": \"coclico\"})" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "9", | ||
"metadata": {}, | ||
"source": [ | ||
"## Read data" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "10", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"da = rioxarray.open_rasterio(href, chunks={}, lock=False).squeeze().drop_vars(\"band\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "11", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"da.where(lambda xx: xx != xx.attrs[\"_FillValue\"]).hvplot(\n", | ||
" x=\"x\", y=\"y\", geo=True, tiles=\"ESRI\"\n", | ||
")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "12", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python [conda env:coastal-full] *", | ||
"language": "python", | ||
"name": "conda-env-coastal-full-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.12.7" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters