<!DOCTYPE html>

bb-page1-catch-bycatch

bb-page1-catch-bycatch

Exploration of outputs in page 1 of the atlas.

# Sys.setenv("POSTGRES_USER" = "diadesatlas_owner")
# Sys.setenv("POSTGRES_PASS" = "thinkrpassword")
pkgload::load_all(here::here())
#> ℹ Loading diades.atlas
library(dplyr)
session <- shiny::MockShinySession$new() #new.env()
connect(session)
con <- get_con(session)
library(rworldmap)
#> Le chargement a nécessité le package : sp
#> ### Welcome to rworldmap ###
#> For a short introduction type :   vignette('rworldmap')
library(rworldxtra)
library(tmap)
library(sf)
#> Linking to GEOS 3.8.0, GDAL 3.0.4, PROJ 6.3.1
library(DBI)

Sys.setenv(
  "GOLEM_CONFIG_ACTIVE" = "dev"
)

Liste des espèces

get_active_species(
  session = session
)
#> # A tibble: 11 × 5
#>    species_id latin_name           english_name        local_name   active
#>         <int> <chr>                <chr>               <chr>        <lgl> 
#>  1          4 Acipenser sturio     European sturgeon   ASturio      TRUE  
#>  2          6 Alosa alosa          Allis shad          AAlosa       TRUE  
#>  3          8 Alosa fallax         Twaite shad         AFallax      TRUE  
#>  4         13 Anguilla anguilla    European eel        AAnguilla    TRUE  
#>  5         18 Lampetra fluviatilis River lamprey       LFluviatilis TRUE  
#>  6         20 Osmerus eperlanus    European smelt      OEperlanus   TRUE  
#>  7         21 Petromyzon marinus   Sea lamprey         PMarinus     TRUE  
#>  8         22 Platichthys flesus   European flounder   PFlesus      TRUE  
#>  9         25 Salmo salar          Atlantic salmon     SSalar       TRUE  
#> 10         26 Salmo trutta         Sea trout           STrutta      TRUE  
#> 11         19 Chelon ramada        Thinlip grey mullet LRamada      TRUE

Conservation status

species <- get_active_species(
  session = session
)
for (i in species$species_id) {
  cli::cat_rule(i)
  print(
    get_conservation_status(
      6,
      con
    )
  )
  cli::cat_line()
}
#> ── 4 ───────────────────────────────────────────────────────────────────────────────────────────────────────────
#>   species_id  latin_name simplified_name english_name iucn_classification_code iucn_level_code
#> 1          6 Alosa alosa        A. alosa   Allis shad              IUCN_Europe              LC
#> 2          6 Alosa alosa        A. alosa   Allis shad                  IUCN_ES              LC
#> 3          6 Alosa alosa        A. alosa   Allis shad                  IUCN_FR              CR
#> 4          6 Alosa alosa        A. alosa   Allis shad                  IUCN_IE              DD
#> 5          6 Alosa alosa        A. alosa   Allis shad                  IUCN_PT              EN
#>         iucn_level_name
#> 1         Least Concern
#> 2         Least Concern
#> 3 Critically Endangered
#> 4        Data Deficient
#> 5            Endangered
#> 
#> ── 6 ───────────────────────────────────────────────────────────────────────────────────────────────────────────
#>   species_id  latin_name simplified_name english_name iucn_classification_code iucn_level_code
#> 1          6 Alosa alosa        A. alosa   Allis shad              IUCN_Europe              LC
#> 2          6 Alosa alosa        A. alosa   Allis shad                  IUCN_ES              LC
#> 3          6 Alosa alosa        A. alosa   Allis shad                  IUCN_FR              CR
#> 4          6 Alosa alosa        A. alosa   Allis shad                  IUCN_IE              DD
#> 5          6 Alosa alosa        A. alosa   Allis shad                  IUCN_PT              EN
#>         iucn_level_name
#> 1         Least Concern
#> 2         Least Concern
#> 3 Critically Endangered
#> 4        Data Deficient
#> 5            Endangered
#> 
#> ── 8 ───────────────────────────────────────────────────────────────────────────────────────────────────────────
#>   species_id  latin_name simplified_name english_name iucn_classification_code iucn_level_code
#> 1          6 Alosa alosa        A. alosa   Allis shad              IUCN_Europe              LC
#> 2          6 Alosa alosa        A. alosa   Allis shad                  IUCN_ES              LC
#> 3          6 Alosa alosa        A. alosa   Allis shad                  IUCN_FR              CR
#> 4          6 Alosa alosa        A. alosa   Allis shad                  IUCN_IE              DD
#> 5          6 Alosa alosa        A. alosa   Allis shad                  IUCN_PT              EN
#>         iucn_level_name
#> 1         Least Concern
#> 2         Least Concern
#> 3 Critically Endangered
#> 4        Data Deficient
#> 5            Endangered
#> 
#> ── 13 ──────────────────────────────────────────────────────────────────────────────────────────────────────────
#>   species_id  latin_name simplified_name english_name iucn_classification_code iucn_level_code
#> 1          6 Alosa alosa        A. alosa   Allis shad              IUCN_Europe              LC
#> 2          6 Alosa alosa        A. alosa   Allis shad                  IUCN_ES              LC
#> 3          6 Alosa alosa        A. alosa   Allis shad                  IUCN_FR              CR
#> 4          6 Alosa alosa        A. alosa   Allis shad                  IUCN_IE              DD
#> 5          6 Alosa alosa        A. alosa   Allis shad                  IUCN_PT              EN
#>         iucn_level_name
#> 1         Least Concern
#> 2         Least Concern
#> 3 Critically Endangered
#> 4        Data Deficient
#> 5            Endangered
#> 
#> ── 18 ──────────────────────────────────────────────────────────────────────────────────────────────────────────
#>   species_id  latin_name simplified_name english_name iucn_classification_code iucn_level_code
#> 1          6 Alosa alosa        A. alosa   Allis shad              IUCN_Europe              LC
#> 2          6 Alosa alosa        A. alosa   Allis shad                  IUCN_ES              LC
#> 3          6 Alosa alosa        A. alosa   Allis shad                  IUCN_FR              CR
#> 4          6 Alosa alosa        A. alosa   Allis shad                  IUCN_IE              DD
#> 5          6 Alosa alosa        A. alosa   Allis shad                  IUCN_PT              EN
#>         iucn_level_name
#> 1         Least Concern
#> 2         Least Concern
#> 3 Critically Endangered
#> 4        Data Deficient
#> 5            Endangered
#> 
#> ── 20 ──────────────────────────────────────────────────────────────────────────────────────────────────────────
#>   species_id  latin_name simplified_name english_name iucn_classification_code iucn_level_code
#> 1          6 Alosa alosa        A. alosa   Allis shad              IUCN_Europe              LC
#> 2          6 Alosa alosa        A. alosa   Allis shad                  IUCN_ES              LC
#> 3          6 Alosa alosa        A. alosa   Allis shad                  IUCN_FR              CR
#> 4          6 Alosa alosa        A. alosa   Allis shad                  IUCN_IE              DD
#> 5          6 Alosa alosa        A. alosa   Allis shad                  IUCN_PT              EN
#>         iucn_level_name
#> 1         Least Concern
#> 2         Least Concern
#> 3 Critically Endangered
#> 4        Data Deficient
#> 5            Endangered
#> 
#> ── 21 ──────────────────────────────────────────────────────────────────────────────────────────────────────────
#>   species_id  latin_name simplified_name english_name iucn_classification_code iucn_level_code
#> 1          6 Alosa alosa        A. alosa   Allis shad              IUCN_Europe              LC
#> 2          6 Alosa alosa        A. alosa   Allis shad                  IUCN_ES              LC
#> 3          6 Alosa alosa        A. alosa   Allis shad                  IUCN_FR              CR
#> 4          6 Alosa alosa        A. alosa   Allis shad                  IUCN_IE              DD
#> 5          6 Alosa alosa        A. alosa   Allis shad                  IUCN_PT              EN
#>         iucn_level_name
#> 1         Least Concern
#> 2         Least Concern
#> 3 Critically Endangered
#> 4        Data Deficient
#> 5            Endangered
#> 
#> ── 22 ──────────────────────────────────────────────────────────────────────────────────────────────────────────
#>   species_id  latin_name simplified_name english_name iucn_classification_code iucn_level_code
#> 1          6 Alosa alosa        A. alosa   Allis shad              IUCN_Europe              LC
#> 2          6 Alosa alosa        A. alosa   Allis shad                  IUCN_ES              LC
#> 3          6 Alosa alosa        A. alosa   Allis shad                  IUCN_FR              CR
#> 4          6 Alosa alosa        A. alosa   Allis shad                  IUCN_IE              DD
#> 5          6 Alosa alosa        A. alosa   Allis shad                  IUCN_PT              EN
#>         iucn_level_name
#> 1         Least Concern
#> 2         Least Concern
#> 3 Critically Endangered
#> 4        Data Deficient
#> 5            Endangered
#> 
#> ── 25 ──────────────────────────────────────────────────────────────────────────────────────────────────────────
#>   species_id  latin_name simplified_name english_name iucn_classification_code iucn_level_code
#> 1          6 Alosa alosa        A. alosa   Allis shad              IUCN_Europe              LC
#> 2          6 Alosa alosa        A. alosa   Allis shad                  IUCN_ES              LC
#> 3          6 Alosa alosa        A. alosa   Allis shad                  IUCN_FR              CR
#> 4          6 Alosa alosa        A. alosa   Allis shad                  IUCN_IE              DD
#> 5          6 Alosa alosa        A. alosa   Allis shad                  IUCN_PT              EN
#>         iucn_level_name
#> 1         Least Concern
#> 2         Least Concern
#> 3 Critically Endangered
#> 4        Data Deficient
#> 5            Endangered
#> 
#> ── 26 ──────────────────────────────────────────────────────────────────────────────────────────────────────────
#>   species_id  latin_name simplified_name english_name iucn_classification_code iucn_level_code
#> 1          6 Alosa alosa        A. alosa   Allis shad              IUCN_Europe              LC
#> 2          6 Alosa alosa        A. alosa   Allis shad                  IUCN_ES              LC
#> 3          6 Alosa alosa        A. alosa   Allis shad                  IUCN_FR              CR
#> 4          6 Alosa alosa        A. alosa   Allis shad                  IUCN_IE              DD
#> 5          6 Alosa alosa        A. alosa   Allis shad                  IUCN_PT              EN
#>         iucn_level_name
#> 1         Least Concern
#> 2         Least Concern
#> 3 Critically Endangered
#> 4        Data Deficient
#> 5            Endangered
#> 
#> ── 19 ──────────────────────────────────────────────────────────────────────────────────────────────────────────
#>   species_id  latin_name simplified_name english_name iucn_classification_code iucn_level_code
#> 1          6 Alosa alosa        A. alosa   Allis shad              IUCN_Europe              LC
#> 2          6 Alosa alosa        A. alosa   Allis shad                  IUCN_ES              LC
#> 3          6 Alosa alosa        A. alosa   Allis shad                  IUCN_FR              CR
#> 4          6 Alosa alosa        A. alosa   Allis shad                  IUCN_IE              DD
#> 5          6 Alosa alosa        A. alosa   Allis shad                  IUCN_PT              EN
#>         iucn_level_name
#> 1         Least Concern
#> 2         Least Concern
#> 3 Critically Endangered
#> 4        Data Deficient
#> 5            Endangered

Tmap code

datasets <- generate_datasets(
  get_con(
    session
  )
)
#> ── generate_datasets ───────────────────────────────────────────────────────────────────────────────────────────

# options("golem.app.prod" = FALSE)
launch_mongo(session = session)
#> MongoDB has not been started or does not exist
#> Using local RAM memory for this session
# NOTE: the species are passed with the latin name in the foreground.
# In the front of the app, the user will have to select an english/french name
tm_draw(
  species_latin_name = "Salmo trutta",
  spatial_type = "rectangle",
  con = con,
  dataCatchment = datasets$dataCatchment,
  catchment_geom = datasets$catchment_geom,
  dataALL = datasets$dataALL,
  ices_geom = datasets$ices_geom,
  session = session
)
#> Some legend labels were too wide. These labels have been resized to 0.13. Increase legend.width (argument of tm_layout) to make the legend wider and therefore the labels larger.
#> Legend labels were too wide. The labels have been resized to 0.13, 0.15, 0.13, 0.11, 0.18. Increase legend.width (argument of tm_layout) to make the legend wider and therefore the labels larger.


tm_draw(
  species_latin_name = "Salmo trutta",
  spatial_type = "division",
  con = con,
  dataCatchment = datasets$dataCatchment,
  catchment_geom = datasets$catchment_geom,
  dataALL = datasets$dataALL,
  ices_geom = datasets$ices_geom,
  session = session
)
#> Some legend labels were too wide. These labels have been resized to 0.13. Increase legend.width (argument of tm_layout) to make the legend wider and therefore the labels larger.
#> Legend labels were too wide. The labels have been resized to 0.13, 0.15, 0.13, 0.11, 0.18. Increase legend.width (argument of tm_layout) to make the legend wider and therefore the labels larger.


tm_draw(
  species_latin_name = "Chelon ramada",
  spatial_type = "rectangle",
  con = con,
  dataCatchment = datasets$dataCatchment,
  catchment_geom = datasets$catchment_geom,
  dataALL = datasets$dataALL,
  ices_geom = datasets$ices_geom,
  session = session
)
#> Some legend labels were too wide. These labels have been resized to 0.13. Increase legend.width (argument of tm_layout) to make the legend wider and therefore the labels larger.
#> Legend labels were too wide. The labels have been resized to 0.13, 0.15, 0.13, 0.11, 0.18. Increase legend.width (argument of tm_layout) to make the legend wider and therefore the labels larger.


tm1 <- tm_draw(
  species_latin_name = "Chelon ramada",
  spatial_type = "division",
  con = con,
  dataCatchment = datasets$dataCatchment,
  catchment_geom = datasets$catchment_geom,
  dataALL = datasets$dataALL,
  ices_geom = datasets$ices_geom,
  session = session
)
tm1
#> Some legend labels were too wide. These labels have been resized to 0.13. Increase legend.width (argument of tm_layout) to make the legend wider and therefore the labels larger.
#> Legend labels were too wide. The labels have been resized to 0.13, 0.15, 0.13, 0.11, 0.18. Increase legend.width (argument of tm_layout) to make the legend wider and therefore the labels larger.

# tmap_leaflet(tm1)

Disconnect db

DBI::dbDisconnect(con)