{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Compute smoother centerlines" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This notebook describes how to compute centerlines with OGGM and write them to disk. It is meant for users who are mostly interested in the centerlines, not so much the rest of the model.\n", "\n", "We use an example of a user-provided glacier inventory and DEM (thanks to [Liss Andreassen](https://www.nve.no/hydrology/our-researchers/liss-marie-andreassen/) for providing the data)." ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import rioxarray as rioxr\n", "import geopandas as gpd\n", "import matplotlib.pyplot as plt\n", "\n", "from oggm import cfg, utils, workflow, tasks" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Data preparation" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "fpath_inventory = 'zip://BreFlate20182019.zip/BreFlate20182019.shp'\n", "fpath_dem = 'norgedtm10nov21.tif'" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Read the data" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "inventory = gpd.read_file(fpath_inventory)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "In this inventory, a few geometries have a topological error (the figure of eight where the outlines touch):" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | objektType | \n", "breID | \n", "brenavn | \n", "breType | \n", "areal_km2 | \n", "forstedata | \n", "datakilde | \n", "metode | \n", "sceneID | \n", "hovedbreID | \n", "... | \n", "vassdragsO | \n", "FTEMA | \n", "GlobalID | \n", "created_us | \n", "created_da | \n", "last_edite | \n", "last_edi_1 | \n", "Shape_STAr | \n", "Shape_STLe | \n", "geometry | \n", "
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
8 | \n", "None | \n", "3161 | \n", "None | \n", "0 | \n", "0.02 | \n", "2019-08-27 | \n", "None | \n", "None | \n", "47 | \n", "0 | \n", "... | \n", "None | \n", "0 | \n", "None | \n", "FS_BRE | \n", "2021-11-12 | \n", "FS_BRE | \n", "2021-11-12 | \n", "2.248363e+04 | \n", "1021.901894 | \n", "POLYGON ((100216.542 6912509.442, 100236.493 6... | \n", "
92 | \n", "None | \n", "1956 | \n", "None | \n", "0 | \n", "0.18 | \n", "2019-08-27 | \n", "None | \n", "None | \n", "47 | \n", "0 | \n", "... | \n", "None | \n", "0 | \n", "None | \n", "FS_BRE | \n", "2021-11-12 | \n", "FS_BRE | \n", "2021-11-12 | \n", "1.826024e+05 | \n", "4047.790603 | \n", "POLYGON ((92498.356 6900920.848, 92500.210 690... | \n", "
159 | \n", "None | \n", "2456 | \n", "None | \n", "0 | \n", "0.19 | \n", "2019-08-27 | \n", "None | \n", "None | \n", "47 | \n", "0 | \n", "... | \n", "None | \n", "0 | \n", "None | \n", "FS_BRE | \n", "2021-11-12 | \n", "FS_BRE | \n", "2021-11-12 | \n", "1.932463e+05 | \n", "4669.023657 | \n", "POLYGON ((91962.885 6883230.562, 91965.661 688... | \n", "
387 | \n", "None | \n", "2605 | \n", "Liabreen | \n", "0 | \n", "0.62 | \n", "2019-08-27 | \n", "None | \n", "None | \n", "47 | \n", "0 | \n", "... | \n", "None | \n", "0 | \n", "None | \n", "FS_BRE | \n", "2021-11-12 | \n", "FS_BRE | \n", "2021-11-12 | \n", "6.171481e+05 | \n", "6595.974453 | \n", "POLYGON ((120594.079 6853553.546, 120595.925 6... | \n", "
523 | \n", "None | \n", "2656 | \n", "Fannaråkbreen | \n", "0 | \n", "2.75 | \n", "2019-08-27 | \n", "None | \n", "None | \n", "47 | \n", "0 | \n", "... | \n", "None | \n", "0 | \n", "None | \n", "FS_BRE | \n", "2021-11-12 | \n", "FS_BRE | \n", "2021-11-12 | \n", "2.747803e+06 | \n", "15241.345864 | \n", "POLYGON ((124543.417 6842414.252, 124543.816 6... | \n", "
... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
6643 | \n", "Breflate | \n", "2290 | \n", "None | \n", "0 | \n", "11.41 | \n", "2019-08-27 | \n", "None | \n", "None | \n", "45 | \n", "7 | \n", "... | \n", "None | \n", "0 | \n", "None | \n", "FS_BRE | \n", "2021-11-12 | \n", "FS_BRE | \n", "2021-11-12 | \n", "1.141095e+07 | \n", "24954.300295 | \n", "POLYGON ((63155.410 6869314.958, 63181.449 686... | \n", "
6649 | \n", "Breflate | \n", "2306 | \n", "Flatebreen | \n", "0 | \n", "0.40 | \n", "2019-08-27 | \n", "None | \n", "None | \n", "45 | \n", "2059 | \n", "... | \n", "None | \n", "0 | \n", "None | \n", "FS_BRE | \n", "2021-11-12 | \n", "FS_BRE | \n", "2021-11-12 | \n", "4.046787e+05 | \n", "5277.768078 | \n", "POLYGON ((63964.380 6864753.248, 63965.304 686... | \n", "
6719 | \n", "Breflate | \n", "2266 | \n", "Lodalsbreen | \n", "0 | \n", "8.76 | \n", "2019-08-27 | \n", "None | \n", "None | \n", "45 | \n", "1 | \n", "... | \n", "None | \n", "0 | \n", "None | \n", "FS_BRE | \n", "2021-11-12 | \n", "FS_BRE | \n", "2021-11-12 | \n", "8.758818e+06 | \n", "42808.850408 | \n", "POLYGON ((91018.242 6874020.521, 90986.386 687... | \n", "
6721 | \n", "Breflate | \n", "2237 | \n", "None | \n", "0 | \n", "0.59 | \n", "2019-08-27 | \n", "None | \n", "None | \n", "45 | \n", "0 | \n", "... | \n", "None | \n", "0 | \n", "None | \n", "FS_BRE | \n", "2021-11-12 | \n", "FS_BRE | \n", "2021-11-12 | \n", "5.943676e+05 | \n", "6680.173218 | \n", "POLYGON ((88863.476 6878889.301, 88873.452 687... | \n", "
6725 | \n", "Breflate | \n", "6762 | \n", "Storefonnbreen | \n", "0 | \n", "0.93 | \n", "2019-08-27 | \n", "None | \n", "None | \n", "45 | \n", "1 | \n", "... | \n", "None | \n", "0 | \n", "None | \n", "FS_BRE | \n", "2021-11-12 | \n", "FS_BRE | \n", "2021-11-12 | \n", "9.274839e+05 | \n", "9173.311529 | \n", "POLYGON ((89582.043 6864493.669, 89582.967 686... | \n", "
67 rows × 22 columns
\n", "\n", " | RGIID | \n", "SEGMENT_ID | \n", "LE_SEGMENT | \n", "MAIN | \n", "geometry | \n", "breID | \n", "
---|---|---|---|---|---|---|
0 | \n", "RGI60-08.00001 | \n", "0 | \n", "322.0 | \n", "1 | \n", "LINESTRING (118270.857 6914371.200, 118278.618... | \n", "1855 | \n", "
1 | \n", "RGI60-08.00002 | \n", "0 | \n", "358.0 | \n", "1 | \n", "LINESTRING (118573.658 6913783.719, 118579.630... | \n", "3156 | \n", "
2 | \n", "RGI60-08.00003 | \n", "0 | \n", "314.0 | \n", "1 | \n", "LINESTRING (117411.558 6913657.999, 117412.239... | \n", "3157 | \n", "
3 | \n", "RGI60-08.00004 | \n", "0 | \n", "332.0 | \n", "1 | \n", "LINESTRING (117804.659 6913611.777, 117809.950... | \n", "1859 | \n", "
4 | \n", "RGI60-08.00005 | \n", "0 | \n", "215.0 | \n", "1 | \n", "LINESTRING (138401.165 6909220.080, 138407.784... | \n", "3158 | \n", "