In-situ snow depth

Row

Regionalization of snow depth stations

Statistical grouping of the station observations of snow depth

An automatic procedure (clustering) based solely on daily snow depth observations from December to April. No information on location or elevation entered into the clustering procedure, so the resulting groups are based solely on the similarity in daily snow depths across 30 years (1981-2010).

Note that because it is a fully automatic procedure, no relabeling was performed, and some stations might seem to belong to the “wrong” group, but actually they have no similar neighbors in their or other clusters.

The grouping reflects the major influences on snow cover, first the elevation, followed by north-south gradients and east-west gradients.

EO SCD

Row

Snow cover duration (SCD) from Earth Observation (EO)

Average number of days with snow on the ground for the period 2000-2020, as observed by MODIS on board the Terra and Aqua satellites.

The anomalies of SCD are relative to elevation. They are calculated by taking each pixel SCD (snow cover duration) minus the areal average SCD over the whole domain at similar elevation (+-50m).

The snow cover duration map shows the main impact on snow cover, namely elevation, while the anomalies highlight the north-south and east-west gradients, after having accounted for elevation.

Row

Explore climatic boundaries

Row

Explore climatic boundaries and snow cover regions

The climatic boundaries have been taken from the HISTALP project and reflect the leading climatological subregions in the European Alps.

The orography of the Alps manifests itself in climatological boundaries. Especially important for snow cover are the temperature and precipitation patterns. These boundaries are reflected in the snow cover regions, both based on in-situ snow depth as well as remotely sensed snow cover duration.

Toggle layers!

Row

Interactive map

---
title: "Snow climatology | CliRSnow"
output: 
  flexdashboard::flex_dashboard:
    storyboard: false
    self_contained: false
    lib_dir: libs
    theme: bootstrap
    orientation: rows
    vertical_layout: fill
    social: menu
    source: embed
    logo: other/logo_72x48.png
    favicon: other/logo_72x48.png
    navbar:
      - { icon: "fa-share", title: "Main Dash", href: "./", align: right }
---

```{r setup, include=FALSE}
library(flexdashboard)
library(leaflet)
library(leafsync)
# library(mapview)
library(leaflegend)

library(raster)
library(sf)
library(stars)
library(ggplot2)
library(dplyr)
```





# In-situ snow depth

## Row

### Regionalization of snow depth stations

```{r stn-plotly}

dat_meta_cluster <- readRDS(here::here("data/meta-with-cluster-01.rds"))
sf_meta <- st_as_sf(dat_meta_cluster,
                    coords = c("Longitude", "Latitude"),
                    crs = 4326)
sf_meta <- sf_meta %>% mutate(Region = cluster_fct)
# sf_meta <- sf_meta %>% mutate(lbl = paste0(Name, " (", Elevation, "m)"))


sf_borders <- st_as_sf(maps::map("world", plot = F, fill = T)) %>% 
  dplyr::filter(ID %in% c("Austria", "France", "Germany",
                          "Italy", "Slovenia", "Switzerland",
                          "Croatia", "Hungary", "Czech Republic",
                          "Slovakia"))

sf_borders2 <- sf_borders %>% 
  mutate(geom = st_cast(geom, "MULTILINESTRING")) %>% 
  # st_crop(sf_meta)
  st_crop(c(xmin = 4.5, ymin = 42.9, xmax = 18, ymax = 49.5))

gg <- ggplot()+
  # borders()+
  geom_sf(data = sf_borders2)+
  geom_sf(data = sf_meta, aes(colour = Region, shape = Region))+
  xlab(NULL)+ylab(NULL)+
  scale_x_continuous(labels = function(x) paste0(x, "° E"))+
  scale_y_continuous(labels = function(x) paste0(x, "° N"))+
  coord_sf(xlim = range(dat_meta_cluster$Longitude), ylim = range(dat_meta_cluster$Latitude))+
  theme_bw()+
  # theme(# legend.position = c(0.65, 0.15),
  #   legend.position = "top",
  #   # legend.title = element_blank(),
  #   legend.background = element_rect(colour = "grey"),
  #   # legend.direction = "horizontal",
  #   legend.box.just = "right")+
  scale_shape("")+
  scale_color_brewer("", palette = "Set1")
  # ggtitle("Regionalization of snow depth stations")


plotly::ggplotly(gg, tooltip = "shape")

```

### Statistical grouping of the station observations of snow depth {data-width=300}

An automatic procedure (clustering) based solely on daily snow depth observations from December to April. No information on location or elevation entered into the clustering procedure, so the resulting groups are based solely on the similarity in daily snow depths across 30 years (1981-2010). 

Note that because it is a fully automatic procedure, no relabeling was performed, and some stations might seem to belong to the "wrong" group, but actually they have no similar neighbors in their or other clusters.

The grouping reflects the major influences on snow cover, first the **elevation**, followed by  **north-south gradients** and **east-west gradients**.


# EO SCD


## Row {data-height=300}

### Snow cover duration (SCD) from Earth Observation (EO)

Average number of days with snow on the ground for the period 2000-2020, as observed by [MODIS](https://en.wikipedia.org/wiki/Moderate_Resolution_Imaging_Spectroradiometer) on board the Terra and Aqua satellites. 

The anomalies of SCD are relative to elevation. They are calculated by taking each pixel SCD (snow cover duration) minus the areal average SCD over the whole domain at similar elevation (+-50m).

The snow cover duration map shows the main impact on snow cover, namely **elevation**, while the anomalies highlight the **north-south and east-west gradients**, after having accounted for elevation.




## Row {data-height=800}


```{r}

rr_scd_1km <- raster(here::here("data/modis_scd_1km_webmerc.tif"))
rr_scd_anom_1km <- raster(here::here("data/modis_scd_anom_1km_webmerc.tif"))

pal_scd <- colorNumeric(scico::scico(palette = "davos", 10),
                        c(0, 366), 
                        na.color = NA)


max_diff <- max(abs(rr_scd_anom_1km[]), na.rm = T)

pal_scd_anom <- colorNumeric(scico::scico(palette = "vik", 11),
                             c(-max_diff, max_diff), 
                             na.color = NA,
                             reverse = T)

lf_scd <-
leaflet() %>% 
  addProviderTiles("CartoDB.Positron") %>% 
  addRasterImage(rr_scd_1km, 
                 opacity = 0.8,
                 colors = pal_scd,
                 project = F) %>% 
  addLegend(pal = pal_scd, 
            values = values(rr_scd_1km),
            opacity = 0.8,
            title = "SCD [days]")


lf_scd_anom <-
leaflet() %>% 
  addProviderTiles("CartoDB.Positron") %>% 
  addRasterImage(rr_scd_anom_1km, 
                 opacity = 0.8,
                 colors = pal_scd_anom,
                 project = F) %>% 
  addLegend(pal = pal_scd_anom, 
            values = values(rr_scd_anom_1km),
            opacity = 0.8,
            title = "anomalies [days]")


sync(lf_scd, lf_scd_anom)

```


# Explore climatic boundaries


## Row {data-height=200}

### Explore climatic boundaries and snow cover regions


The climatic boundaries have been taken from the [HISTALP](http://www.zamg.ac.at/histalp/project/maps/gar_reg.php) project and reflect the leading climatological subregions in the European Alps. 


The **orography** of the Alps manifests itself in **climatological boundaries**. Especially important for snow cover are the **temperature and precipitation patterns**. These boundaries are **reflected in the snow cover** regions, both based on in-situ snow depth as well as remotely sensed snow cover duration.


### {data-width=150}

```{r}
valueBox("Toggle layers!", icon = "fa-level-down-alt")
```


## Row {data-height=800}


### Interactive map


```{r}

sf_histalp <- readRDS(here::here("data/sf_histalp_extended.rds"))
load(here::here("data/viz_past.Rdata"))


sf_lines_crs <- sf_histalp[c(1,3), ] %>% 
  st_cast("MULTILINESTRING") %>%
  summarise(geometry = st_combine(geometry)) %>% 
  st_crop(c(xmin = 3, ymin = 42.2, xmax = 20, ymax = 49)) 


sf_lines_t <- histalp_reg_t[c(2,3), ]%>%
  st_cast("MULTILINESTRING") %>%
  summarise(geometry = st_combine(geometry)) %>% 
  st_crop(c(xmin = 4.1, ymin = 43.1, xmax = 19, ymax = 48.7))


sf_lines_p <- histalp_reg_p[c(2,3), ]%>%
  st_cast("MULTILINESTRING") %>%
  summarise(geometry = st_combine(geometry)) %>% 
  st_crop(c(xmin = 4.1, ymin = 43.1, xmax = 19, ymax = 48.7)) 


leaflet() %>% 
  addProviderTiles("CartoDB.Positron", group = "CartoDB") %>% 
  addProviderTiles("Esri.WorldTopoMap", group = "Topomap") %>% 
  addProviderTiles("Esri.WorldImagery", group = "WorldImagery") %>% 
  
  addRasterImage(rr_scd_1km,
                 opacity = 1,
                 colors = pal_scd,
                 project = F,
                 group = "SCD") %>%
  # addLegend(pal = pal_scd,
  #           values = values(rr_scd_1km),
  #           opacity = 0.8,
  #           title = "SCD [days]",
  #           position = "topleft") %>%

  addRasterImage(rr_scd_anom_1km,
                 opacity = 1,
                 colors = pal_scd_anom,
                 project = F,
                 group = "SCD anomalies") %>%
  # addLegend(pal = pal_scd_anom,
  #           values = values(rr_scd_anom_1km),
  #           opacity = 0.8,
  #           title = "SCD anomalies [days]",
  #           position = "topleft") %>%

  addCircleMarkers(data = sf_meta,
                   stroke = F,
                   fillOpacity = 0.8,
                   radius = 5,
                   color = ~ mv5_leaf_col(Region),
                   group = "In-situ snow depth regions") %>% 
  addLegendFactor(pal = mv5_leaf_col, 
                  values = sf_meta$Region,
                  shape = "circle",
                  width = 20, height = 20,
                  opacity = 0.8,
                  title = "In-situ snow depth regions",
                  position = "bottomleft",
                  group = "In-situ snow depth regions") %>% 
  

  addPolylines(data = sf_lines_crs,
               color = "black",
               opacity = 0.8,
               group = "HISTALP Summary") %>% 
  addPolylines(data = sf_lines_t,
               color = "#b30000",
               opacity = 0.8,
               group = "HISTALP Temperature") %>% 
  addPolylines(data = sf_lines_p,
               color = "#045a8d",
               opacity = 0.8,
               group = "HISTALP Precipitation") %>% 
  addLegend(colors = c("black",
                       "#b30000",
                       "#045a8d"),
            labels = c("summary climatic boundaries",
                       "temperature boundaries",
                       "precipitation boundaries"),
            opacity = 0.8,
            title = "HISTALP",
            position = "bottomleft") %>% 
  
  addLayersControl(baseGroups = c("CartoDB", "Topomap", "WorldImagery"),
                   overlayGroups = c("SCD", "SCD anomalies",
                                     "In-situ snow depth regions",
                                     "HISTALP Summary", 
                                     "HISTALP Temperature", 
                                     "HISTALP Precipitation"),
                   position = "topright",
                   options = layersControlOptions(collapsed = FALSE)) %>% 
  hideGroup("SCD") %>%
  hideGroup("SCD anomalies")

```