-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.R
More file actions
74 lines (59 loc) · 1.85 KB
/
app.R
File metadata and controls
74 lines (59 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
library(mapgl)
library(shiny)
library(bslib)
library(shinythemes)
ui <- page_sidebar(
title = "Map the gaps!",
sidebar = sidebar(
selectInput("taxa",
selected = "plant",
"Select a species group",
choices = c("Reptiles" = "ar",
"Mammals" = "mammal",
"Plants" = "plant",
"Vertebrates" = "vert"))
),
card(
full_screen = TRUE,
maplibreCompareOutput("map")
),
# Use the darkly theme
theme = shinythemes::shinytheme("sandstone")
)
server <- function(input, output, session) {
sel_taxa <- reactive({
readRDS(paste0("outputs/m-richness-", input$taxa, ".rds"))
})
sel_io_url <- reactive({
if(input$taxa == "mammal"){
taxonname = "Mammalia"
}
if(input$taxa == "plant"){
taxonname = "Plantae"
}
if(input$taxa == "ar"){
taxonname = "Reptilia" ## NOTE: this is wrong, we need Amphibia too but trying for now ----
}
if(input$taxa == "vert"){
taxonname = "Animalia" ## NOTE: this is wrong, Animalia has inverts too ----
}
paste0("https://tiler.biodiversite-quebec.ca/cog/tiles/{z}/{x}/{y}?url=https://object-arbutus.cloud.computecanada.ca/bq-io/io/inat_canada_heatmaps/",taxonname, "_density_inat_1km.tif&rescale=0,1&colormap_name=magma&bidx=1&expression=b1")
})
output$map <- renderMaplibreCompare({
m1 = maplibre(bounds = c(-177.40777,35.93066,-12.79625,71.44204),
style = carto_style("dark-matter")) |>
add_raster_source(
id = "inat",
tiles= sel_io_url()
) |>
add_raster_layer(
id = 'inat-layer',
source = 'inat',
raster_opacity = .5
) |>
add_fullscreen_control(position = "top-left") |>
add_navigation_control()
mapgl::compare(m1, sel_taxa())
})
}
shinyApp(ui, server)