2 Indicator data: calculations and visualizations

The basis for the Nature Index (NI) calculations are the indicator data. These are observations, model estimates, or expert judgements that quantify the state (typically abundance) of the different indicator species, species groups, or habitat types.

The “raw” indicator data, including associated reference values, are stored in the NI database (https://naturindeks.nina.no/). As part of the presentation of NI2025, we want to present the following for each individual indicator:

  • Raw indicator values, by area, as time-series plots
  • Raw indicator values, by area, as pair of value and uncertainty maps
  • Scaled indicator values, by area, as time-series plots
  • Scaled indicator values, by area, as pairs of value and uncertainty maps
  • Area-averaged indicator values (referred to as “indicator index” in the documentation from NI2020), as part of the time-series plots for scaled indicator values

The area-averaged indicator values are also required to be fed back into the NI database as a separate table that can be used for corresponding visualizations on the webpage.

2.1 General setup

There are a few variables that are used to control execution of parts of the code in this chapter. We start off by defining these here:

## Indicator focal years
ind_focalYears <- c(1990, 1995, 2000, 2005, 2010, 2014, 2019, 2024)

## Toggle for using/ignoring reference value uncertainty in visualizations
#uncertainRefValue <- TRUE
uncertainRefValue <- FALSE

## Toggle for visualizing scaled values truncated before or after summarising
truncAfterSummary <- TRUE
#truncAfterSummary <- FALSE

Additionally, we will define and set a seed to ensure reproducibility of the simulations:

mySeed <- 0
set.seed(mySeed)

2.2 Connect to the Nature Index Database

To access and download indicator data, we need to retrieve a token from the NI database. For that to work, we need access to our NI database access credentials; we retrieve those from environmental variables (if you have not saved them as environmental variables, you can find the code for doing that in chapter 0; alternatively, you can also manually set them here):

NIdb_username <- Sys.getenv("NIdb_username")
NIdb_password <- Sys.getenv("NIdb_password")

After retrieving login credentials, we can open a connection / request a token:

NIcalc::getToken(username = NIdb_username,  
                 password = NIdb_password,
                 url = "https://www8.nina.no/NaturindeksNiCalc")

2.3 List indicators and retrieve data

If the person running this script has full access to the database (admin rights), they should be able to access the complete list of indicators by directly pulling it from the database using NIcalc::getIndicators():

indicatorList <- NIcalc::getIndicators() %>%
  dplyr::arrange(name)

saveRDS(indicatorList, file = "data/NI2025_IndicatorList.rds")

Alternatively, you can read in the saved version of the indicator list that comes with this repository:

indicatorList <- readRDS("data/NI2025_IndicatorList.rds")

The list is contains a total of 203 indicators, and is ordered alphabetically:

indicatorList
##      id                                    name
## 1     3                           Alge på bjørk
## 2   250                                    Alke
## 3     5                                     Alm
## 4     7                  Atlantisk høgmyr areal
## 5    50                                    Aure
## 6     9                           Bananslørsopp
## 7    10                         Begerfingersopp
## 8    11     Begroing elver eutrofierings indeks
## 9   233        Begroing elver forsurings indeks
## 10   12                               Berggylte
## 11  399                              Bjørkefink
## 12   23                                  Blåbær
## 13   16                               Blåkveite
## 14   18                               Blåskjell
## 15  390                               Blåstrupe
## 16   20            Blåtopp i fuktig kystlynghei
## 17  343         Bløtbunn artsmangfold fauna hav
## 18   21        Bløtbunn artsmangfold fauna kyst
## 19   22                  Bløtbunn eutrofiindeks
## 20  398                                 Bokfink
## 21  282                                  Boltit
## 22   27                                  Brosme
## 23   29                               Brunbjørn
## 24  338                               Brunmyrak
## 25   31        Bunndyr elver forventningsamfunn
## 26  228      Bunndyr-eutrofieringsindeks (ASPT)
## 27  231     Bunndyr-forsuringsindeks (Raddum 1)
## 28  351                  Dagsommerfugler i skog
## 29  416         Dagsommerfugler i åpent lavland
## 30  340                             Dikesoldogg
## 31  410                                  Dompap
## 32  314                                Duetrost
## 33   36          Dyreplankton artssammensetning
## 34   38                               Edelkreps
## 35   41               Eldre lauvsuksesjon (MiS)
## 36   42                                     Elg
## 37   43                             Elvemusling
## 38  211                             Engmarihand
## 39  150                           Engvokssopper
## 40  301                          Enkeltbekkasin
## 41   49                               Fiolgubbe
## 42  268                     Fiskemåke ferskvann
## 43  242                          Fiskemåke kyst
## 44  284                               Fjellerke
## 45   52                                Fjellrev
## 46   53                               Fjellrype
## 47   54                             Fjellvalmue
## 48  286                                Fjellvåk
## 49  392                              Flaggspett
## 50   28                          Flekkhvitkjuke
## 51  270                               Fossekall
## 52  110                              Fossenever
## 53  407                              Fuglekonge
## 54   60                        Gamle trær (MiS)
## 55  434                             Gammel skog
## 56   62                                   Gaupe
## 57  408                             Gjerdesmett
## 58  303                              Gluttsnipe
## 59  317                                Granmeis
## 60  318                              Gransanger
## 61   66                                Greplyng
## 62  414                         Grå fluesnapper
## 63  245                                 Gråmåke
## 64   68                            Grønlandssel
## 65   69                          Grønn fåresopp
## 66   72                              Grønngylte
## 67  394                              Grønnspett
## 68  304                              Grønnstilk
## 69  305                                 Gulerle
## 70  335                               Gulsanger
## 71  412                              Hagesanger
## 72   74          Hardbunn vegetasjon algeindeks
## 73   75   Hardbunn vegetasjon nedre voksegrense
## 74  287                                 Havelle
## 75  234                                 Havhest
## 76  235                                 Havsule
## 77  257                                  Havørn
## 78  288                                   Heilo
## 79  289                             Heipiplerke
## 80   77                                   Hjort
## 81  359                           Humler i skog
## 82  417                  Humler i åpent lavland
## 83  337                               Hvitmyrak
## 84   84                                    Hyse
## 85  319                               Hønsehauk
## 86   85                                Issoleie
## 87   86                       Isterviersumpskog
## 88  400                               Jernspurv
## 89   88                                    Jerv
## 90   89                            Jordstjerner
## 91   90                              Jordtunger
## 92  438          Karplanter i semi-naturlig eng
## 93   92                               Klappmyss
## 94   95                                 Kolmule
## 95  322                                Kongeørn
## 96   98                      Kopperrød slørsopp
## 97  385                                Krikkand
## 98  247                                 Krykkje
## 99  100                                 Kusymre
## 100 101                                  Kveite
## 101 386                                 Kvinand
## 102  94                             Køllesopper
## 103 104                    Laks - kyst og elver
## 104 360                            Laks i havet
## 105 105                                   Lange
## 106 106                               Lappkjuke
## 107 290                               Lappspurv
## 108 439               Lavhei i villreinkommuner
## 109 108     Liggende død ved (MiS) – arealandel
## 110 419               Liggende død ved – mengde
## 111 109                                  Lirype
## 112 111                                   Lodde
## 113 251                                   Lomvi
## 114 253                                   Lunde
## 115 324                               Løvsanger
## 116 115                                 Makrell
## 117 248                            Makrellterne
## 118 326                                    Munk
## 119 307                                Myrsnipe
## 120 125                                 Myrtelg
## 121 325                                Måltrost
## 122 396                             Nøtteskrike
## 123 130                              Olavsstake
## 124 384                                 Orrfugl
## 125 134                  Oter ferskvannsbestand
## 126 135                        Oter kystbestand
## 127 142                           Palsmyr areal
## 128 145                  Planteplankton (Chl a)
## 129 146                 Planteplankton innsjøer
## 130 252                              Polarlomvi
## 131 149                           Praktrødspore
## 132 151                             Prestekrage
## 133 152                              Purpurlyng
## 134 389                                    Ravn
## 135 156                               Reker hav
## 136 409                                 Ringdue
## 137 391                               Ringtrost
## 138 433                          Rogn-Osp-Selje
## 139 153                                   Rådyr
## 140 249                            Rødnebbterne
## 141 308                                Rødstilk
## 142 406                               Rødstjert
## 143 402                               Rødstrupe
## 144 395                           Rødvingetrost
## 145 165                                     Sei
## 146 167                               Sennegras
## 147 298                                  Siland
## 148 369              Sild - havgående bestander
## 149 440                               Sildemåke
## 150 310                                Sivspurv
## 151 339                             Smalsoldogg
## 152 370             Smågnagere - fjellbestander
## 153 332              Smågnagere - skogbestander
## 154 275                                  Smålom
## 155 311                                Småspove
## 156 291                                Snøspurv
## 157 180                                 Solblom
## 158 292                             Steinskvett
## 159 333                                Stokkand
## 160 186                                Storfugl
## 161 241                                  Storjo
## 162 277                                 Storlom
## 163 187                  Storpiggslekten (sopp)
## 164 236                     Storskarv ssp carbo
## 165 237                  Storskarv ssp sinensis
## 166 278                             Strandsnipe
## 167 183      Stående død ved (MiS) – arealandel
## 168 418                Stående død ved – mengde
## 169 296                                Svartand
## 170 246                                Svartbak
## 171 328                   Svarthvit fluesnapper
## 172 222                            Svartkutling
## 173 403                               Svartmeis
## 174 194                    Svartnende kantarell
## 175 195                          Svartsonekjuke
## 176 393                              Svartspett
## 177 397                              Svarttrost
## 178 196                              Sveltstarr
## 179 312                             Svømmesnipe
## 180 436                                 Tamrein
## 181 254                                   Teist
## 182 202                    Tilstand kystlynghei
## 183 201 Tilstand semi-naturlig eng og strandeng
## 184 415                                   Tjeld
## 185 203                                   Tobis
## 186 279                                 Toppand
## 187 330                                Toppmeis
## 188 239                               Toppskarv
## 189 378                   Torsk - havsbestander
## 190 313                                   Trane
## 191 405                               Trekryper
## 192 401                             Trepiplerke
## 193 207                 Trær med hengelav (MiS)
## 194 209                                     Ulv
## 195 380                        Ungsild (1-2 år)
## 196 208                              Vanlig uer
## 197 213                      Vannplanter innsjø
## 198 215                       Vier alpint belte
## 199 216                                Villrein
## 200   1                                      Ål
## 201 293                                  Ærfugl
## 202 141                                  Øyepål

Now that we have all indicators listed we can download the entire set of indicator data. This takes a while to run, and we therefore save the data import as a local file after it finished downloading so that we do not have to re-download the entire dataset repeatedly.

indicatorImport <- list()

for(i in 1:nrow(indicatorList)){
  indicatorImport[[i]] <- NIcalc::importDatasetApi(
    username = NIdb_username,
    password = NIdb_password,
    indic = indicatorList$name[i]
  )
}

names(indicatorImport) <- indicatorList$id

saveRDS(indicatorImport, "data/indicatorImport.rds")

The next step in the NI workflow is “assembling” the data. This step makes sure that the parameters characterizing uncertainty distributions for indicator values are present for all data points (see documentation of NIcalc::assembleNiObject() for more details). This also requires some time to run, and like the previous step, we will save the output so we can work directly from that afterwards.

indicatorData <- list()

for(i in 1:nrow(indicatorList)){
  indicatorData[[i]] <- NIcalc::assembleNiObject(
    inputData = indicatorImport[[i]],
    predefNIunits = c(allArea = TRUE, parts = TRUE, counties = FALSE),
    indexType = "thematic"
  )
}

names(indicatorData) <- indicatorList$id

saveRDS(indicatorData, "data/indicatorData_assembled.rds")

2.4 Simulate indicator value distributions

For visualizing indicator values (both original and scaled), we need associated measures of uncertainty. While all indicator value have such information associated in the database, the format thereof varies, i.e. some indicators have lower and upper quartiles in addition to means reported, while others are specified via custom distributions.

We require a standardized way for presenting values including uncertainty across all indicators. In previous iterations of NI, it seems that results were displayed as median plus 95% confidence interval (= 2.5% and 97.5% quantiles, according to NINA Report 1990, “Nature Index System Documentation”). While working with alternative approaches to visualizing indicator data, we also experimented with using coefficient of variation (= relative standard deviation = sd/mean) for visualizing uncertainty in maps (see here https://ninanor.github.io/NIviz/maps-1.html), and displays of the entire indicator value distributions (e.g. 5.1 here: https://ninanor.github.io/NIviz/other-figures.html).

Based on this, we have a need for a) different measures of uncertainty and b) samples of draws from the uncertainty distributions of all indicators. We can obtain all of this information from simulations. The function simulate_IndicatorData() can be used to run the corresponding simulations for all indicators and years with available data:

## Source functions
source("R/simulate_IndicatorData.R")
source("R/scale_IndicatorValues.R")

## Make folder for storing data as files
if(!dir.exists("data/simulated_IndicatorData")){
  dir.create("data/simulated_IndicatorData")
}

## Set up list for storing all results
simData <- list()

## For all indicators, simulate data from distributions and save as files and in list

for(i in 1:nrow(indicatorList)){
  message("")
  message(crayon::bold(crayon::green(paste0(indicatorList$name[i]))))
  
  simData_i <- simulate_IndicatorData(indData = indicatorData[[i]])
  
  simData[[i]] <- simData_i
  
  saveRDS(simData_i, file = paste0("data/simulated_IndicatorData/simData_id_", indicatorList$id[i], ".rds"))
  message("")
}

## Save total list containing all datasets
saveRDS(simData, file = "data/simulated_IndicatorData/simData_all.rds")

2.5 Summarize indicator value distributions

In the next step, we want to calculated some summary metrics for our indicator data. The helper function summarise_IndicatorDist() takes the raw and scaled indicator datasets and calculates the following metrics for each year- and area-specific indicator value:

  • Mean
  • Median
  • Standard deviation
  • Relative standard deviation
  • 2.5%, 5%, 25%, 75%, 95%, and 97.5% quantiles

We first source the function, and then run it on each of the three datasets (raw, scaled with fixed reference, scaled with sampled reference) available for all indicators. The results we will save as local .rds and .csv files.

## Source function
source("R/summarise_IndicatorDist.R")

## Make folder for storing data as files
if(!dir.exists("data/IndicatorData_StatSummaries")){
  dir.create("data/IndicatorData_StatSummaries")
}

savePath <- "data/IndicatorData_StatSummaries/"

## Re-set seed
set.seed(mySeed)

## Summarise indicator value distributions for all datasets and indicators
for(i in 1:nrow(indicatorList)){
  message(crayon::bold(crayon::green(paste0(indicatorList$name[i]))))
  
  # Raw (unscaled data)
  summarise_IndicatorDist(indSim = simData[[i]]$raw,
                          ind_id = indicatorList$id[i],
                          dataset_name = "raw",
                          savePath = savePath)
  
  # Scaled using fixed reference
  summarise_IndicatorDist(indSim = simData[[i]]$scaled_fixedRef,
                          ind_id = indicatorList$id[i],
                          dataset_name = "scaled_fixedRef",
                          savePath = savePath)
  
  # Scaled using sampled reference
  summarise_IndicatorDist(indSim = simData[[i]]$scaled_sampledRef,
                          ind_id = indicatorList$id[i],
                          dataset_name = "scaled_sampledRef",
                          savePath = savePath)
  message("")
}

2.6 Calculating indicator indices

Traditionally, time-series of area-aggregated indicator values have been published for a selection of indicators on the NI webpage. These are referred to as “indicator indices” and are calculated using the same framework as the NI for different ecosystems (via NIcalc::calculateIndex()). We calculate these here using the wrapper function calculate_IndicatorIndex(). The source code underlying this function originates from scripts from NI2020 stored on NINA’s internal servers under “R:/Prosjekter/12892000_naturindeks_rammeverk_database_og_innsynslosning/Naturindeks 2020/Beregninger/Indikatorer/”. Back then, indicator indices were calculated on a per-ecosystem basis, likely to circumvent the issue that no alternative had been coded into “NIcalc” yet. In calculate_IndicatorIndex() here, we have made adjustments that allow calculating indicator indices taking into account all relevant ecosystems; in practice, this means that area weights are determined by the extent of area within each spatial unit covered by any of the ecosystems relevant to the indicator (as opposed to just one selected one). It’s still possible to calculate indicator indices specific to single ecosystems too by setting weigh_byEcosystem = TRUE and specifying which ecosystem in the call to the function. However, for the purpose of visualizing indicator data, we will work with indicator indices calculated for all relevant ecosystems.

Below, we loop over all indicators to calculate indicator indices, and save the results into a list for further use in R and as files into a designated folder:

## Source function
source("R/calculate_IndicatorIndex.R")

## Create folder for saving results
if(!dir.exists("results_Indicators")){
  dir.create("results_Indicators")
}

## Set up list for storing results
indIndex <- list()

## Calculate indicator indices and save results, per indicator
for(i in 1:nrow(indicatorList)){

  indIndex_i <- calculate_IndicatorIndex(dataSet = indicatorData[[i]],
                                     testRun = FALSE,
                                     NAimputation = FALSE,
                                     weigh_byEcosystem = FALSE,
                                     include_subAreas = TRUE,
                                     truncAtRef = TRUE,
                                     enforce_weightSum1 = TRUE)
  indIndex[[i]] <- indIndex_i
  
  readr::write_excel_csv(indIndex_i$summary, file = paste0("results_Indicators/indIndex_Summary_id_", indicatorList$id[i], ".csv"))
  
  saveRDS(indIndex_i, paste0("results_Indicators/indIndex_id_", indicatorList$id[i], ".rds"))
}

Note that we are calculating indicator indices without imputations (NAimputation = FALSE). This is because imputation using the “mice” algorithm will not work very well for many indicators due to limited data and high collinearity. It works for indices combining many indicators because that translates to more (variable) data. Without imputations, indicator indices for selected years represent area-weighted means of values for the areas with available data in the specified year. Since different areas may have data available for different years, changes in calculated indicator indices over time have to be interpreted with caution as changes may indicate a) changes in average indicator values and/or b) changes in composition of areas with values. We assist this visually by not “connecting” the indicator index estimates across years below.

2.7 Visualizing raw and scaled indicator data

For the remainder of this chapter, we will work with one indicator at a time and read in the respective simulated datasets anew. This means we can remove the large objects containing data for all indicators simultaneously from the workspace:

rm(simData, indicatorData, indicatorImport, indIndex)

There are two types of visualizations of indicator data that we are aiming for:

  1. Time-series plots of medians and 95% confidence intervals (featuring lines for different areas)
  2. Year-specific maps of a) medians and b) uncertainty as relative standard deviation

Both visualizations will be done for the unscaled (raw) and scaled indicator values.

Below, we present the corresponding visualizations in indicator-specific sub-chapters. There are a few things to note:

  • The defaults for visualization of scaled indicator values are using uncertainty statistics truncated after summarising, and treating the calculations based on fixed references as the baseline. This can be changed using the toggles truncAfterSummary and uncertainRefValue at the start of this script.
  • Visualizations will be partially displayed in this document, and also saved as files.
  • In this document, we will display 1. featuring all areas. We will not draw and display maps here as these will be part of the presentation of data and results on the new NI webpage.
  • For now, the visualizations are static. The goal for the website is to have interactive elements in the figures, including: menus to toggle on and off different time series (and reference levels), “sliders” to change year for maps, simultaneous highlights in median and uncertainty maps, etc.
  • Visualizations of the entire value distributions (see under 5.1. here: https://ninanor.github.io/NIviz/other-figures.html) will not be done for individual indicators (only for the aggregated NI for the different ecosystems).

First, we set up directories, determine which scaled values file to use, define a plot color to use in cases where we have time series for many areas, and set up lists to store the plots in R:

## Set up folder for plots (if not present already)
if(!dir.exists("plots")){
  dir.create("plots")
}

## Select correct file for scaled data
filename_scaled <- dplyr::case_when(
  !uncertainRefValue & truncAfterSummary ~ "fixedRef",
  !uncertainRefValue & !truncAfterSummary ~ "fixedRef_truncPreSum",
  uncertainRefValue & truncAfterSummary ~ "sampledRef",
  uncertainRefValue & !truncAfterSummary ~ "sampledRef_truncPreSum",
)

## Set fixed plotting colors

# Time-series plot color for indicators with > 20 areas
plot.col <- "#D37295FF"

# Time-series plot color for indicator indices
plot.col2 <- "#0B2120"

## Make lists to store plots for each indicator
TS_raw <- list()
TS_scaled <- list()
TS_indIdx <- list()
TS_indIdx_std <- list()

Then, we proceed to plot time series and save plots to files:

for(i in 1:nrow(indicatorList)){
  
  ## Extract indicator name and id
  ind_id <- indicatorList$id[i]
  ind_name <- indicatorList$name[i]
  
  message(crayon::bold(crayon::green(paste0(ind_name))))
  
  ## Make subfolder for species in target directory & set save path
  if(!dir.exists(paste0("plots/id_", ind_id, "_", stringr::str_replace_all(ind_name, " ", "_")))){
    dir.create(paste0("plots/id_", ind_id, "_", stringr::str_replace_all(ind_name, " ", "_")))
  }
  savePath_i <- paste0("plots/id_", ind_id, "_", stringr::str_replace_all(ind_name, " ", "_"))
  
  ## Load indicator datasets
  message("Processing indicator data...")
  
  data_raw <- readRDS(paste0("data/IndicatorData_StatSummaries/statSummary_id_", ind_id, "_raw.rds")) %>%
    dplyr::mutate(year_t = as.integer(year))
  
  data_scaled <- readRDS(paste0("data/IndicatorData_StatSummaries/statSummary_id_", ind_id, "_scaled_", filename_scaled, ".rds")) %>%
    dplyr::mutate(year_t = as.integer(year))
  
  output_indIdx <- readRDS(paste0("results_Indicators/indIndex_id_", ind_id, ".rds"))
  
  data_indIdx <- output_indIdx$summary %>%
    dplyr::filter(indexArea == "wholeArea", year_t %in% ind_focalYears & !data_singleArea) %>% 
    dplyr::mutate(year_t = as.integer(year_t))
  
  ## Truncate scaled values (if necessary)
  data_rows <- c("mean", "median", "q025", "q05", "q25", "q75", "q95", "q975") 
  
  data_scaled <- data_scaled %>%
    dplyr::mutate(dplyr::across(.cols = all_of(data_rows), ~ ifelse(. > 1, 1, .)))
  
  ## Count areas for picking time series display
  manyAreas <- ifelse(length(unique(data_raw$ICunitName)) > 20, TRUE, FALSE)
  
  ## Set years to highlight
  minYear <- min(data_raw$year_t)
  maxYear <- max(data_raw$year_t)
  
  if(minYear >= ind_focalYears[1]){
    plot.yearH <- ind_focalYears[which(ind_focalYears >= minYear)]
  }else{
    plot.yearH <- unique(c(minYear, rev(seq(from = ind_focalYears[1], to = minYear, by = -5)), ind_focalYears))
  }
  
  ## Prepare time series plots for each indicator
  message("Drawing time-series plots...")
  
  # Raw data
  if(!manyAreas){
    ts_raw <- ggplot(data_raw, aes(x = year_t)) + 
      geom_point(aes(y = median, color = ICunitName)) + 
      geom_errorbar(aes(ymin = q025, ymax = q975, color = ICunitName), width = 0.5, alpha = 0.25) + 
      geom_line(aes(y = median, color = ICunitName)) + 
      xlab("Year") + ylab("Indicator value (unscaled)") + 
      ggtitle(ind_name) +
      paletteer::scale_color_paletteer_d(palette = "ggthemes::Tableau_20", name = "Area") +
      scale_x_continuous(breaks = plot.yearH) + 
      theme_bw() + 
      theme(legend.position = "bottom", 
            panel.grid.minor = element_blank(),
            axis.text.x = element_text(angle = 45, vjust = 0.8))
  }else{
    ts_raw <- ggplot(data_raw, aes(x = year_t)) + 
      geom_point(aes(y = median, group = ICunitName), color = plot.col, alpha = 0.2) + 
      geom_errorbar(aes(ymin = q025, ymax = q975, group = ICunitName), width = 0.5, color = plot.col, alpha = 0.1) + 
      geom_line(aes(y = median, group = ICunitName), color = plot.col, alpha = 0.2) + 
      xlab("Year") + ylab("Indicator value (unscaled)") + 
      ggtitle(ind_name) +
      scale_x_continuous(breaks = plot.yearH) + 
      theme_bw() + 
      theme(legend.position = "bottom", 
            panel.grid.minor = element_blank(),
            axis.text.x = element_text(angle = 45, vjust = 0.8))
  }
  
  TS_raw[[i]] <- ts_raw
  ggsave(file = paste0(savePath_i, "/TimeSeries_raw.svg"), plot = ts_raw, width = 8, height = ifelse(manyAreas, 5, 6.5))
  ggsave(file = paste0(savePath_i, "/TimeSeries_raw.pdf"), plot = ts_raw, width = 8, height = ifelse(manyAreas, 5, 6.5))
  ggsave(file = paste0(savePath_i, "/TimeSeries_raw.png"), plot = ts_raw,width = 8, height = ifelse(manyAreas, 5, 6.5), dpi = 150)
  
  # Scaled data
  if(!manyAreas){
    ts_scaled <- ggplot(data_scaled, aes(x = year_t)) + 
      geom_point(aes(y = median, color = ICunitName)) + 
      geom_errorbar(aes(ymin = q025, ymax = q975, color = ICunitName), width = 0.5, alpha = 0.25) + 
      geom_line(aes(y = median, color = ICunitName)) + 
      geom_errorbar(data = data_indIdx, aes(x = year_t, ymin = q025, ymax = q975), width = 0.5, color = plot.col2) + 
      geom_point(data = data_indIdx, aes(x = year_t, y = median), shape = 21, size = 2, stroke = 1.5, fill = "white", color = plot.col2) +
      ylim(0, 1.01) + 
      xlab("Year") + ylab("Indicator value (scaled)") + 
      ggtitle(ind_name) +
      paletteer::scale_color_paletteer_d(palette = "ggthemes::Tableau_20", name = "Area") + 
      scale_x_continuous(breaks = plot.yearH) + 
      theme_bw() + 
      theme(legend.position = "bottom", 
            panel.grid.minor = element_blank(),
            axis.text.x = element_text(angle = 45, vjust = 0.8))
  }else{
    ts_scaled <- ggplot(data_scaled, aes(x = year_t)) + 
      geom_point(aes(y = median, group = ICunitName), color = plot.col, alpha = 0.2) + 
      geom_errorbar(aes(ymin = q025, ymax = q975, group = ICunitName), width = 0.5, color = plot.col, alpha = 0.1) + 
      geom_line(aes(y = median, group = ICunitName), color = plot.col, alpha = 0.2) +
      geom_errorbar(data = data_indIdx, aes(x = year_t, ymin = q025, ymax = q975), width = 0.5, color = plot.col2) + 
      geom_point(data = data_indIdx, aes(x = year_t, y = median), shape = 21, size = 2, stroke = 1.5, fill = "white", color = plot.col2) +
      ylim(0, 1) + 
      xlab("Year") + ylab("Indicator value (scaled)") + 
      ggtitle(ind_name) +
      scale_x_continuous(breaks = plot.yearH) + 
      theme_bw() + 
      theme(legend.position = "bottom", 
            panel.grid.minor = element_blank(),
            axis.text.x = element_text(angle = 45, vjust = 0.8))
  }
  
  TS_scaled[[i]] <- ts_scaled
  ggsave(file = paste0(savePath_i, "/TimeSeries_scaled.svg"), plot = ts_scaled, width = 8, height = ifelse(manyAreas, 5, 6.5))
  ggsave(file = paste0(savePath_i, "/TimeSeries_scaled.pdf"), plot = ts_scaled, width = 8, height = ifelse(manyAreas, 5, 6.5))
  ggsave(file = paste0(savePath_i, "/TimeSeries_scaled.png"), plot = ts_scaled, width = 8, height = ifelse(manyAreas, 5, 6.5), dpi = 150)
  
  
  # Indicator indices (average and sub-areas)
  ts_indIdx <- NIflex::plotNI_StandardTS(Index = output_indIdx$indexOutput,
                                         plotTitle = paste0(ind_name, " (arealvektet gjennomsnitt)"),
                                         plotYears = ind_focalYears,
                                         addAverage = TRUE,
                                         truncateY = TRUE) + 
    theme(axis.text.x = element_text(angle = 30, vjust = 0.8))
  
  ts_indIdx2 <- NIflex::plotNI_StandardTS(Index = output_indIdx$indexOutput,
                                          plotTitle = paste0(ind_name, " (arealvektet gjennomsnitt)"),
                                          plotYears = ind_focalYears,
                                          addAverage = TRUE,
                                          truncateY = FALSE) + 
    theme(axis.text.x = element_text(angle = 30, vjust = 0.8))
  
  TS_indIdx[[i]] <- ts_indIdx
  ggsave(file = paste0(savePath_i, "/TimeSeries_indIdx.svg"), plot = ts_indIdx, width = 7, height = 4)
  ggsave(file = paste0(savePath_i, "/TimeSeries_indIdx.pdf"), plot = ts_indIdx, width = 7, height = 4)
  ggsave(file = paste0(savePath_i, "/TimeSeries_indIdx.png"), plot = ts_indIdx, width = 7, height = 4, dpi = 150)
  
  TS_indIdx_std[[i]] <- ts_indIdx2
  ggsave(file = paste0(savePath_i, "/TimeSeries_indIdx_std.svg"), plot = ts_indIdx2, width = 7, height = 4)
  ggsave(file = paste0(savePath_i, "/TimeSeries_indIdx_std.pdf"), plot = ts_indIdx2, width = 7, height = 4)
  ggsave(file = paste0(savePath_i, "/TimeSeries_indIdx_std.png"), plot = ts_indIdx2, width = 7, height = 4, dpi = 150)
  
  message("")
}

## Save entire plot lists for re-use later
saveRDS(TS_raw, file = "results_Indicators/PlotList_TimeSeries_raw.rds")
saveRDS(TS_scaled, file = "results_Indicators/PlotList_TimeSeries_scaled.rds")
saveRDS(TS_indIdx, file = "results_Indicators/PlotList_TimeSeries_indIdx.rds")
saveRDS(TS_indIdx_std, file = "results_Indicators/PlotList_TimeSeries_indIdx_std.rds")

2.8 Indicator presentation

Below, we show the time series plots for raw and scaled indicator data.

2.8.1 Alge på bjørk

2.8.2 Alke

2.8.3 Alm

2.8.4 Atlantisk høgmyr areal

2.8.5 Aure

2.8.6 Bananslørsopp

2.8.7 Begerfingersopp

2.8.8 Begroing elver eutrofierings indeks

2.8.9 Begroing elver forsurings indeks

2.8.10 Berggylte

2.8.11 Bjørkefink

2.8.12 Blåbær

2.8.13 Blåkveite

2.8.14 Blåskjell

2.8.15 Blåstrupe

2.8.16 Blåtopp i fuktig kystlynghei

2.8.17 Bløtbunn artsmangfold fauna hav

2.8.18 Bløtbunn artsmangfold fauna kyst

2.8.19 Bløtbunn eutrofiindeks

2.8.20 Bokfink

2.8.21 Boltit

2.8.22 Brosme

2.8.23 Brunbjørn

2.8.24 Brunmyrak

2.8.25 Bunndyr elver forventningsamfunn

2.8.26 Bunndyr-eutrofieringsindeks (ASPT)

2.8.27 Bunndyr-forsuringsindeks (Raddum 1)

2.8.28 Dagsommerfugler i skog

2.8.29 Dagsommerfugler i åpent lavland

2.8.30 Dikesoldogg

2.8.31 Dompap

2.8.32 Duetrost

2.8.33 Dyreplankton artssammensetning

2.8.34 Edelkreps

2.8.35 Eldre lauvsuksesjon (MiS)

2.8.36 Elg

2.8.37 Elvemusling

2.8.38 Engmarihand

2.8.39 Engvokssopper

2.8.40 Enkeltbekkasin

2.8.41 Fiolgubbe

2.8.42 Fiskemåke ferskvann

2.8.43 Fiskemåke kyst

2.8.44 Fjellerke

2.8.45 Fjellrev

2.8.46 Fjellrype

2.8.47 Fjellvalmue

2.8.48 Fjellvåk

2.8.49 Flaggspett

2.8.50 Flekkhvitkjuke

2.8.51 Fossekall

2.8.52 Fossenever

2.8.53 Fuglekonge

2.8.54 Gamle trær (MiS)

2.8.55 Gammel skog

2.8.56 Gaupe

2.8.57 Gjerdesmett

2.8.58 Gluttsnipe

2.8.59 Granmeis

2.8.60 Gransanger

2.8.61 Greplyng

2.8.62 Grå fluesnapper

2.8.63 Gråmåke

2.8.64 Grønlandssel

2.8.65 Grønn fåresopp

2.8.66 Grønngylte

2.8.67 Grønnspett

2.8.68 Grønnstilk

2.8.69 Gulerle

2.8.70 Gulsanger

2.8.71 Hagesanger

2.8.72 Hardbunn vegetasjon algeindeks

2.8.73 Hardbunn vegetasjon nedre voksegrense

2.8.74 Havelle

2.8.75 Havhest

2.8.76 Havsule

2.8.77 Havørn

2.8.78 Heilo

2.8.79 Heipiplerke

2.8.80 Hjort

2.8.81 Humler i skog

2.8.82 Humler i åpent lavland

2.8.83 Hvitmyrak

2.8.84 Hyse

2.8.85 Hønsehauk

2.8.86 Issoleie

2.8.87 Isterviersumpskog

2.8.88 Jernspurv

2.8.89 Jerv

2.8.90 Jordstjerner

2.8.91 Jordtunger

2.8.92 Karplanter i semi-naturlig eng

2.8.93 Klappmyss

2.8.94 Kolmule

2.8.95 Kongeørn

2.8.96 Kopperrød slørsopp

2.8.97 Krikkand

2.8.98 Krykkje

2.8.99 Kusymre

2.8.100 Kveite

2.8.101 Kvinand

2.8.102 Køllesopper

2.8.103 Laks - kyst og elver

2.8.104 Laks i havet

2.8.105 Lange

2.8.106 Lappkjuke

2.8.107 Lappspurv

2.8.108 Lavhei i villreinkommuner

2.8.109 Liggende død ved (MiS) – arealandel

2.8.110 Liggende død ved – mengde

2.8.111 Lirype

2.8.112 Lodde

2.8.113 Lomvi

2.8.114 Lunde

2.8.115 Løvsanger

2.8.116 Makrell

2.8.117 Makrellterne

2.8.118 Munk

2.8.119 Myrsnipe

2.8.120 Myrtelg

2.8.121 Måltrost

2.8.122 Nøtteskrike

2.8.123 Olavsstake

2.8.124 Orrfugl

2.8.125 Oter ferskvannsbestand

2.8.126 Oter kystbestand

2.8.127 Palsmyr areal

2.8.128 Planteplankton (Chl a)

2.8.129 Planteplankton innsjøer

2.8.130 Polarlomvi

2.8.131 Praktrødspore

2.8.132 Prestekrage

2.8.133 Purpurlyng

2.8.134 Ravn

2.8.135 Reker hav

2.8.136 Ringdue

2.8.137 Ringtrost

2.8.138 Rogn-Osp-Selje

2.8.139 Rådyr

2.8.140 Rødnebbterne

2.8.141 Rødstilk

2.8.142 Rødstjert

2.8.143 Rødstrupe

2.8.144 Rødvingetrost

2.8.145 Sei

2.8.146 Sennegras

2.8.147 Siland

2.8.148 Sild - havgående bestander

2.8.149 Sildemåke

2.8.150 Sivspurv

2.8.151 Smalsoldogg

2.8.152 Smågnagere - fjellbestander

2.8.153 Smågnagere - skogbestander

2.8.154 Smålom

2.8.155 Småspove

2.8.156 Snøspurv

2.8.157 Solblom

2.8.158 Steinskvett

2.8.159 Stokkand

2.8.160 Storfugl

2.8.161 Storjo

2.8.162 Storlom

2.8.163 Storpiggslekten (sopp)

2.8.164 Storskarv ssp carbo

2.8.165 Storskarv ssp sinensis

2.8.166 Strandsnipe

2.8.167 Stående død ved (MiS) – arealandel

2.8.168 Stående død ved – mengde

2.8.169 Svartand

2.8.170 Svartbak

2.8.171 Svarthvit fluesnapper

2.8.172 Svartkutling

2.8.173 Svartmeis

2.8.174 Svartnende kantarell

2.8.175 Svartsonekjuke

2.8.176 Svartspett

2.8.177 Svarttrost

2.8.178 Sveltstarr

2.8.179 Svømmesnipe

2.8.180 Tamrein

2.8.181 Teist

2.8.182 Tilstand kystlynghei

2.8.183 Tilstand semi-naturlig eng og strandeng

2.8.184 Tjeld

2.8.185 Tobis

2.8.186 Toppand

2.8.187 Toppmeis

2.8.188 Toppskarv

2.8.189 Torsk - havsbestander

2.8.190 Trane

2.8.191 Trekryper

2.8.192 Trepiplerke

2.8.193 Trær med hengelav (MiS)

2.8.194 Ulv

2.8.195 Ungsild (1-2 år)

2.8.196 Vanlig uer

2.8.197 Vannplanter innsjø

2.8.198 Vier alpint belte

2.8.199 Villrein

2.8.200 Ål

2.8.201 Ærfugl

2.8.202 Øyepål