<!DOCTYPE html>
# 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)
library(rworldxtra)
library(tmap)
library(sf)
library(DBI)
library(zeallot)
Sys.setenv(
"GOLEM_CONFIG_ACTIVE" = "dev"
)
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 … European st… ASturio TRUE
#> 2 6 Alosa alosa Allis shad AAlosa TRUE
#> 3 8 Alosa fall… Twaite shad AFallax TRUE
#> 4 13 Anguilla a… European eel AAnguilla TRUE
#> 5 18 Lampetra f… River lampr… LFluviati… TRUE
#> 6 20 Osmerus ep… European sm… OEperlanus TRUE
#> 7 21 Petromyzon… Sea lamprey PMarinus TRUE
#> 8 22 Platichthy… European fl… PFlesus TRUE
#> 9 25 Salmo salar Atlantic sa… SSalar TRUE
#> 10 26 Salmo trut… Sea trout STrutta TRUE
#> 11 19 Chelon ram… Thinlip gre… LRamada TRUE
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
#> 1 6 Alosa alosa A. alosa Allis shad
#> 2 6 Alosa alosa A. alosa Allis shad
#> 3 6 Alosa alosa A. alosa Allis shad
#> 4 6 Alosa alosa A. alosa Allis shad
#> 5 6 Alosa alosa A. alosa Allis shad
#> iucn_classification_code iucn_level_code
#> 1 IUCN_Europe LC
#> 2 IUCN_ES LC
#> 3 IUCN_FR CR
#> 4 IUCN_IE DD
#> 5 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
#> 1 6 Alosa alosa A. alosa Allis shad
#> 2 6 Alosa alosa A. alosa Allis shad
#> 3 6 Alosa alosa A. alosa Allis shad
#> 4 6 Alosa alosa A. alosa Allis shad
#> 5 6 Alosa alosa A. alosa Allis shad
#> iucn_classification_code iucn_level_code
#> 1 IUCN_Europe LC
#> 2 IUCN_ES LC
#> 3 IUCN_FR CR
#> 4 IUCN_IE DD
#> 5 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
#> 1 6 Alosa alosa A. alosa Allis shad
#> 2 6 Alosa alosa A. alosa Allis shad
#> 3 6 Alosa alosa A. alosa Allis shad
#> 4 6 Alosa alosa A. alosa Allis shad
#> 5 6 Alosa alosa A. alosa Allis shad
#> iucn_classification_code iucn_level_code
#> 1 IUCN_Europe LC
#> 2 IUCN_ES LC
#> 3 IUCN_FR CR
#> 4 IUCN_IE DD
#> 5 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
#> 1 6 Alosa alosa A. alosa Allis shad
#> 2 6 Alosa alosa A. alosa Allis shad
#> 3 6 Alosa alosa A. alosa Allis shad
#> 4 6 Alosa alosa A. alosa Allis shad
#> 5 6 Alosa alosa A. alosa Allis shad
#> iucn_classification_code iucn_level_code
#> 1 IUCN_Europe LC
#> 2 IUCN_ES LC
#> 3 IUCN_FR CR
#> 4 IUCN_IE DD
#> 5 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
#> 1 6 Alosa alosa A. alosa Allis shad
#> 2 6 Alosa alosa A. alosa Allis shad
#> 3 6 Alosa alosa A. alosa Allis shad
#> 4 6 Alosa alosa A. alosa Allis shad
#> 5 6 Alosa alosa A. alosa Allis shad
#> iucn_classification_code iucn_level_code
#> 1 IUCN_Europe LC
#> 2 IUCN_ES LC
#> 3 IUCN_FR CR
#> 4 IUCN_IE DD
#> 5 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
#> 1 6 Alosa alosa A. alosa Allis shad
#> 2 6 Alosa alosa A. alosa Allis shad
#> 3 6 Alosa alosa A. alosa Allis shad
#> 4 6 Alosa alosa A. alosa Allis shad
#> 5 6 Alosa alosa A. alosa Allis shad
#> iucn_classification_code iucn_level_code
#> 1 IUCN_Europe LC
#> 2 IUCN_ES LC
#> 3 IUCN_FR CR
#> 4 IUCN_IE DD
#> 5 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
#> 1 6 Alosa alosa A. alosa Allis shad
#> 2 6 Alosa alosa A. alosa Allis shad
#> 3 6 Alosa alosa A. alosa Allis shad
#> 4 6 Alosa alosa A. alosa Allis shad
#> 5 6 Alosa alosa A. alosa Allis shad
#> iucn_classification_code iucn_level_code
#> 1 IUCN_Europe LC
#> 2 IUCN_ES LC
#> 3 IUCN_FR CR
#> 4 IUCN_IE DD
#> 5 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
#> 1 6 Alosa alosa A. alosa Allis shad
#> 2 6 Alosa alosa A. alosa Allis shad
#> 3 6 Alosa alosa A. alosa Allis shad
#> 4 6 Alosa alosa A. alosa Allis shad
#> 5 6 Alosa alosa A. alosa Allis shad
#> iucn_classification_code iucn_level_code
#> 1 IUCN_Europe LC
#> 2 IUCN_ES LC
#> 3 IUCN_FR CR
#> 4 IUCN_IE DD
#> 5 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
#> 1 6 Alosa alosa A. alosa Allis shad
#> 2 6 Alosa alosa A. alosa Allis shad
#> 3 6 Alosa alosa A. alosa Allis shad
#> 4 6 Alosa alosa A. alosa Allis shad
#> 5 6 Alosa alosa A. alosa Allis shad
#> iucn_classification_code iucn_level_code
#> 1 IUCN_Europe LC
#> 2 IUCN_ES LC
#> 3 IUCN_FR CR
#> 4 IUCN_IE DD
#> 5 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
#> 1 6 Alosa alosa A. alosa Allis shad
#> 2 6 Alosa alosa A. alosa Allis shad
#> 3 6 Alosa alosa A. alosa Allis shad
#> 4 6 Alosa alosa A. alosa Allis shad
#> 5 6 Alosa alosa A. alosa Allis shad
#> iucn_classification_code iucn_level_code
#> 1 IUCN_Europe LC
#> 2 IUCN_ES LC
#> 3 IUCN_FR CR
#> 4 IUCN_IE DD
#> 5 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
#> 1 6 Alosa alosa A. alosa Allis shad
#> 2 6 Alosa alosa A. alosa Allis shad
#> 3 6 Alosa alosa A. alosa Allis shad
#> 4 6 Alosa alosa A. alosa Allis shad
#> 5 6 Alosa alosa A. alosa Allis shad
#> iucn_classification_code iucn_level_code
#> 1 IUCN_Europe LC
#> 2 IUCN_ES LC
#> 3 IUCN_FR CR
#> 4 IUCN_IE DD
#> 5 IUCN_PT EN
#> iucn_level_name
#> 1 Least Concern
#> 2 Least Concern
#> 3 Critically Endangered
#> 4 Data Deficient
#> 5 Endangered
dataCatchment <- dbReadTable(
con,
"v_abundance"
) %>%
inner_join(
tribble(
~abundance_level_id, ~abundance_interpretation,
1, "Not recorded in the period",
2, "Occasional vagrants",
3, "Functional populations",
4, "Abundant functional populations"
) %>%
mutate(abundance_interpretation = factor(abundance_interpretation,
levels = .$abundance_interpretation
)),
by = "abundance_level_id"
)
catchment_geom <- st_read(
con,
query = "SELECT * FROM diadesatlas.v_basin vb"
) %>%
rmapshaper::ms_simplify() %>%
st_transform("+proj=wintri")
dataALL <- dbGetQuery(
con,
"SELECT * from diadesatlas.v_species_ices_occurence vsio "
) %>%
# tibble() %>%
mutate(nb_occurence = as.integer(nb_occurence))
ices_geom <- st_read(
con,
query = "SELECT * FROM diadesatlas.v_ices_geom;"
) %>%
# st_transform("+proj=eqearth +wktext") %>%
st_transform("+proj=wintri") %>%
rmapshaper::ms_simplify()
dataContinent <- get_data_continent_m(
session = session
)(
catchment_geom,
dataCatchment,
"Salmo trutta"
)
c(
dataCatchment,
catchment_geom,
dataALL,
ices_geom,
species_list
) %<-% generate_datasets(
get_con(
session
)
)
#> ── generate_datasets ───────────────────────────────────
# options("golem.app.prod" = FALSE)
launch_mongo(session = 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 = dataCatchment,
catchment_geom = catchment_geom,
dataALL = dataALL,
ices_geom = 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 = dataCatchment,
catchment_geom = catchment_geom,
dataALL = dataALL,
ices_geom = 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 = dataCatchment,
catchment_geom = catchment_geom,
dataALL = dataALL,
ices_geom = 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 = "division",
con = con,
dataCatchment = dataCatchment,
catchment_geom = catchment_geom,
dataALL = dataALL,
ices_geom = 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.
DBI::dbDisconnect(con)