# Glacier table

The glacier table allows for a sub-grid representation of the glacier processes, by creating a grid at a finer resolution than the model grid. The glacier table is only required for the SPHY version higher 3.0 and higher. The glacier table contains eight elements (Table 10, Table 11).

**Table 10: Elements of the glacier table**

| Name           | Description                                                                                                                                  |
| -------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
| **U\_ID**      | Unique ID that is set at smaller spatial scale to account for sub grid heterogeneity in the glacier cover                                    |
| **MOD\_ID**    | Individual ID of each cell of the SPHY model                                                                                                 |
| **GLAC\_ID**   | ID of the individual glaciers in the model area, from the RGI inventory, from glacier ID 1 to X (with X being the maximum number of glacier) |
| **MOD\_H**     | Elevation of model ID cell                                                                                                                   |
| **MOD\_GLAC**  | Elevation of subgrid cell                                                                                                                    |
| **DEBRIS**     | A flag (0 or 1) to identify if the cell is debris-covered                                                                                    |
| **FRAC\_GLAC** | The fraction of the cell that is covered by glacier                                                                                          |
| **ICE\_DEPTH** | Ice thickness of the cell                                                                                                                    |

**Table 11: Example of Glacier table**

<table><thead><tr><th width="98">U_ID</th><th width="101">MOD_ID</th><th width="107">GLAC_ID</th><th width="95">MOD_H</th><th width="98">GLAC_H</th><th>DEBRIS</th><th>FRAC_GLAC</th><th>ICE_DEPTH</th></tr></thead><tbody><tr><td><strong>1</strong></td><td>61122</td><td>89</td><td>3946</td><td>3946</td><td>1</td><td>0.002</td><td>0</td></tr><tr><td><strong>2</strong></td><td>61123</td><td>89</td><td>3928</td><td>3928</td><td>1</td><td>0.368</td><td>5.28</td></tr><tr><td><strong>3</strong></td><td>61124</td><td>89</td><td>3897</td><td>3897</td><td>1</td><td>0.189</td><td>7.04</td></tr><tr><td><strong>4</strong></td><td>61937</td><td>89</td><td>3950</td><td>3950</td><td>1</td><td>0.446</td><td>17.31</td></tr><tr><td>...</td><td>...</td><td>...</td><td>...</td><td>...</td><td>...</td><td>...</td><td>...</td></tr></tbody></table>

The suggested method to process these input can be summarized in 4 steps:

1. Create model vector grid (fishnet) (MOD\_ID)
2. Intersect with the glacier outlines (GLAC\_ID)
3. Create subgrid variability grid (U\_ID)
4. Calculate elevation, glacier thickness, debris cover, and glacier fraction (MOD\_H, GLAC\_H, DEBRIS, FRAC\_GLAC, ICE\_DEPTH)

**Step 1: Create model vector grid (MOD\_ID)**

Open a model input raster file with the spatial extent and grid size in QGIS. This could be the clone.map, dem.map, latitude.map, or any raster model grid input. In the Vector Creation toolbox, select the “Create grid” tool. For the “Grid extent”, select the option “Calculate from layer”, and select the model raster. For “Horizontal spacing” and “Vertical spacing”, set the grid size of your model. Set name to “MOD\_ID”.

<figure><img src="https://2432255304-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbpkOf6MyIYzEi0TyV0In%2Fuploads%2FUFHq0GZCVmujJu5Ftuks%2Fafbeelding.png?alt=media&#x26;token=d38ccc0e-cebb-4728-b29f-871c31c7baac" alt=""><figcaption><p>Figure 42: Creating Model_ID grid. Set the Horizontal and Vertical spacing to the model grid resolution.</p></figcaption></figure>

This new vector layer contains polygons for each grid of your model domain, with value starting at 1 in the upper left corner. In the attribute table of your “MOD\_ID” layer (right click on layer, select “Open attribute table” and deleted the attributes “left”, ‘”top”, ‘”right”, “bottom” to keep only the column “id” using the “Delete field” in the attribute table. Rename this attribute to “MOD\_ID” using the tool “Rename field” in the Vector table toolbox. This is now your MOD\_ID vector layer.

**Step 2: Create GLAC\_ID, MOD\_H and glac\_id.map**

Import the vector layer of glacier outline in the model area. This could come from manually digitized glacier areas or from an inventory like RGI7 (RGI 7.0 Consortium, 2023). Clip the glacier outline vector to the model area using the Vector Overlay toolbox “Clip” tool and reproject to the desired projection to match your model projection (toolbox Vector general, “reproject layer” tool). Open the attribute table of the glacier outline layer and create a new attribute using the field calculator (Figure 43).

Using the GDAL toolbox, use the “Rasterize (vector to raster) to transform the GLAC\_ID vector layer to a raster layer GLAC\_ID” (Figure 44), followed by transforming to a .map file by using the PCRaster toolbox with ther tool “Convert to PCRaster format”, with format " NOMINAL” and named glac\_id.map. This is an input for the glacier module in SPHY.

<figure><img src="https://2432255304-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbpkOf6MyIYzEi0TyV0In%2Fuploads%2FOMns8duc4gx6182TBK6X%2Fafbeelding.png?alt=media&#x26;token=17574454-2c9c-4b7b-987a-986dd930b80d" alt=""><figcaption><p>Figure 43: Create GLAC_ID attribute</p></figcaption></figure>

<figure><img src="https://2432255304-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbpkOf6MyIYzEi0TyV0In%2Fuploads%2FVbFJvIgv4VAk8b4jq5g8%2Fafbeelding.png?alt=media&#x26;token=60b1e829-2e63-4295-b430-26a8bc413c56" alt=""><figcaption><p>Figure 44: Rasterize glacier outline to obtain GLAC_ID map layer.</p></figcaption></figure>

You now need to intersect the MOD\_ID grid with the glacier outline to obtain a grid that covers only the glacier area. To do so, intersect the glacier outline vector layer with the MODEL\_ID grid (Vector overlay toolbox, “intersection” tool) with input layer “MOD\_ID” and overlay layer “Glacier Outline”. The resulting layer (GLAC\_ID) has two attributes: MOD\_ID, from the original grid of the model domain, and “GLAC\_ID”, the value of the individual glaciers (Figure 45).

<figure><img src="https://2432255304-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbpkOf6MyIYzEi0TyV0In%2Fuploads%2F3b7LhdSEQOR2ERzEo5EK%2Fafbeelding.png?alt=media&#x26;token=50ddff96-e219-41af-84d8-7c5672c00e57" alt=""><figcaption><p>Figure 45: The GLAC_ID layer (in pink) with two attributes, GLAC_ID and MOD_ID as shown in the attribute table for a cell on the glacier table for a cell on the glacier toe highlighted in yellow, with MOD ID 839 and GLAC_ID 1. The orange grid in the background correspond to the model ID grid. At this stage, the cell size of the GLAC_ID and MOD_ID are the same size.</p></figcaption></figure>

The elevation of the MOD\_ID cells over the glacier area, which corresponds to the column “MOD\_H” in the glacier table, can now be calculated. Import the DEM for your model area. Then, open the tool “Zonal Statistics” in the toolbox Raster analysis (Figure 46). For “Statistics to calculate”, select “mean”. Using the tool “rename field”, rename the resulting field to “MOD\_H”. The resulting raster has three attributes: MOD\_ID, GLAC\_ID, MOD\_H.

<figure><img src="https://2432255304-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbpkOf6MyIYzEi0TyV0In%2Fuploads%2F4OjzBu14rsY1SZUkWIvc%2Fafbeelding.png?alt=media&#x26;token=fe4ec01b-fe1e-42a1-bab1-ec7fbc4b738d" alt=""><figcaption><p>Figure 46: Using the "Zonal statistics" tool to calculate the elevation of the glacier grid.</p></figcaption></figure>

**Step 3: Create sub-grid variability (U\_ID)**

In this step, the smaller grid to account to calculate glacier processes at a higher resolution is created. Also, in some cases, some grid cells have 2 different glaciers within them, so we have to create a smaller gid system to account for this sub-grid variability (Figure 47). To create the U\_ID (the smaller scale grid), follow the same steps as to create the MOD\_ID (step 1), but select a smaller spatial resolution as needed. Create a new attribute, named U\_ID, to start the values at 1 (same as Figure 43 to obtain GLAC\_ID, using the rows as index). Keep only the attribute U\_ID in the vector layer. Intersect the U\_ID with the MOD\_ID vector layer to keep only the smaller grid in the glacier area (using the “Intersect” tool). The resulting vector layer U\_ID has four attributes: MOD\_ID, GLAC\_ID, MOD\_H, and U\_ID (Figure 48).

<figure><img src="https://2432255304-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbpkOf6MyIYzEi0TyV0In%2Fuploads%2FACXQloc0E9mf63cczW5D%2Fafbeelding.png?alt=media&#x26;token=67e6d90a-8750-4cb1-aa55-5cb74dba0002" alt=""><figcaption><p>Figure 47: The need for a smaller grid to account for the multiple glacier in one cell model</p></figcaption></figure>

<figure><img src="https://2432255304-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbpkOf6MyIYzEi0TyV0In%2Fuploads%2FiB7AURZ8U2XCiwJfEQB4%2Fafbeelding.png?alt=media&#x26;token=a9623629-94b3-4a42-b121-e94cbdd5d5fa" alt=""><figcaption><p>Figure 48: The U_ID layer showing the smaller scale grid cell, with the four attributes (MOD_ID, GLAC_ID, MOD_H, and U_ID). The orange background correspond to the larger MOD_ID grid.</p></figcaption></figure>

**Step 4: Calculate the elevation (U\_MOD), glacier thickness (ICE\_DEPTH), debris cover (DEBRIS) and glacier fraction (GLAC\_FRAC):**

In this step, we use the finer grid U\_ID to calculate the values for each grid cell for the various dataset: elevation, the presence of debris, the ice thickness and the fraction glacier cover.&#x20;

For the H\_GLAC (elevation of the glacier), follow the same step as for the MOD\_H calculation with the Zonal Statistics tool (Figure 46) using the original DEM, or an updated, finer resolution DEM is needed. Once again, you can rename the field to ICE\_DEPTH and remove any attribute that are superfluous.

For glacier thickness (ICE\_DEPTH), first load your ice thickness data into QGIS, then use the Zonal Statistic tool. If the ice thickness dataset is not continuous, or comes with multiple files, first merge into a single raster using toolbox SAGA Next Gen (needs to be downloaded as a plugin) raster tools with tool Mosaicking. Set “Overlapping areas” to “maximum”, and create a text file list with all the files to be used in the mosaic. Then using the “Zonal Statistics” tools to calculate the ice thickness for each U\_ID cell. Once again, you can rename the field to ICE\_DEPTH and remove any attribute that are superfluous.

Some ice thickness might show as zero due to some misalignment of the product of a missing glacier in the ice thickness database. For these cases, you can set a fixed value as the glacier thickness. To do so, in the attribute table, open the field calculator, and for the ICE\_DEPTH field, set the expression: if("ICE\_DEPTH" is NULL, 25, " ICE\_DEPTH") (Figure 49). Repeat the procedure for ice\_depth values that are 0.

<figure><img src="https://2432255304-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbpkOf6MyIYzEi0TyV0In%2Fuploads%2FbeHXRL7pt2NN172ZTOXx%2Fafbeelding.png?alt=media&#x26;token=b5dfc5cb-1440-4fe7-92bf-ac068af62bb2" alt=""><figcaption><p>Figure 49: Replacing "NULL" values with ice thickness of 25m, using the layer "_MEAN", THE OUTPUT OF THE Zonal Statistics tool.</p></figcaption></figure>

For the debris-cover, import the debris-cover file, and if in vector format, rasterized using the GDAL toolbox, with tool “Rasterize (vector to raster), with the same resolution as the U\_ID. Set the burn in value to 1. Using the “Zonal statistics” tool, calculate the presence of debris for each pixel of the U\_ID vector. Using the field calculator, change the “NULL” values to “0” (if("\_mean" is NULL, 0, "\_mean"), as in Figure 49 DEBRIS should be either 0 or 1.

For the fraction of glacier cover in a given cell (GLAC\_FRAC), first calculate the area of each polygon with the Vector Geometry toolbox, with tool “add geometry attribute”. This adds area and perimeter to the attribute table. Based on the cell size, you can now calculate the ratio of the cell covered by the glacier. For example, in this case, if the cell is 25 x 25m, the maximum area is 625. Using the field calculator, you can divide the “area” attribute by the maximum area of each cell, giving you the glacier fraction. GLAC\_FRAC should be higher than 0 and maximum of 1.

You should now have a vector layer with eight attributes corresponding to the the 8 columns needed in the glacier table, with the spatial resolution of the smaller grid capturing the glacier processes at higher resolution. Once all the calculation are done and checked, export file as .csv, organize column titles and order, and this gives you the glacier table needed as a SPHY input (Figure 50).

<figure><img src="https://2432255304-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FbpkOf6MyIYzEi0TyV0In%2Fuploads%2FYit6lljgMy184tq5vbyZ%2Fafbeelding.png?alt=media&#x26;token=28ff845d-b8cc-47a3-adc3-959011044aa3" alt=""><figcaption><p>Figure 50: Exporting the vector layer as glac_table.csv</p></figcaption></figure>
