forked from marvinschmitt/quarto-website-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.qmd
More file actions
110 lines (92 loc) · 4.17 KB
/
index.qmd
File metadata and controls
110 lines (92 loc) · 4.17 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
---
format:
html:
code-fold: true
code-download: true
code-overflow: wrap
about:
template: jolla
id: about-block
image-shape: rectangle
image: "img/logo.png"
links:
- icon: twitter
text: Twitter
href: https://x.com/sashamikheyev
- icon: github
text: Github
href: https://github.com/mikheyevlab/coloss
- icon: envelope
text: Email
href: "mailto:alexander.mikheyev@anu.edu.au"
engine: knitr
---
::: {#about-block}
:::
This is a placeholder webpage that illustrates data visualisation and communication capability. Simulated results shown below are analysed on a local computer and rendered as a static HTML that can be uploaded to any web server, or even embedded inside other web pages.
The code repository hosted on GitHub necessary to conduct the analysis, generate the images and render the website will be a key derivable at the end of the project. AgriFutures can continue to host the website for free on GitHub using a custom domain name or transfer it to another server.
**The website will also host a link to the survey (see header above for an example of a fully-functional survey based .on the current New Zealand colony loss survey).**
## Graphics
The graphics below use simulated data to show analytical and display capabilities. The "Code" would not usually be visible, but shows and exampla pipeline going from data simulation to display. These images are interactive using JavaScript capabilities of modern browsers -- the code has already been run offline.
```{r message=F, cache = T}
#| layout-ncol: 2
library(sf)
library(ggplot2)
library(ggiraph)
# Load the shapefile
aus_shp <- st_read("../STE_2021_AUST_GDA2020.shx", quiet = T)[1:8,] # remove islands
# Simplify geometries with a lower tolerance and keep empty shapes
aus_shp_simplified <- st_simplify(aus_shp, dTolerance = 8000, preserveTopology = TRUE)
# Ensure geometries are valid
aus_shp_simplified <- st_make_valid(aus_shp_simplified)
# Remove empty geometries
aus_shp_simplified <- aus_shp_simplified[!st_is_empty(aus_shp_simplified), ]
# Generate random numbers between 1 and 100 for each state
set.seed(123) # For reproducibility
aus_shp_simplified$`2024 colony losses` <- sample(1:20, nrow(aus_shp_simplified), replace = TRUE)
years <- 2020:2024
states <- c("New South Wales", "Victoria", "Queensland", "South Australia", "Western Australia", "Tasmania", "Northern Territory", "Australian Capital Territory")
n_states <- length(states)
colony_losses <- data.frame(
state = rep(states, each = length(years)),
year = rep(years, times = n_states),
losses = sample(1:20, n_states * length(years), replace = TRUE)
)
# Create ggplot object with interactive elements
p <- ggplot(aus_shp_simplified) +
geom_sf_interactive(aes(fill = `2024 colony losses`, tooltip = `2024 colony losses`, data_id = `2024 colony losses`)) +
scale_fill_viridis_c() +
theme_minimal() + theme(panel.grid.major = element_blank(), panel.grid.minor = element_blank(), axis.text = element_blank()) + labs(title = "2024 winter losses") + guides(fill = guide_legend(title = NULL))
# Render the interactive plot
girafe(
ggobj = p,
options = list(
opts_hover(css = "fill:orange;"),
opts_hover_inv(css = "opacity:0.5;"),
opts_selection(type = "single", only_shiny = FALSE),
opts_tooltip(css = "font-size: 20px;")
)
)
p_line <- ggplot(colony_losses, aes(x = year, y = losses, color = state, group = state)) +
geom_line_interactive(aes(tooltip = paste(state, year, losses, sep = ": "), data_id = state)) +
geom_point_interactive(aes(tooltip = paste(state, year, losses, sep = ": "), data_id = state)) +
theme_minimal() +
theme(
panel.grid.major = element_blank(),
panel.grid.minor = element_blank(),
axis.text = element_text(size = 12),
axis.title = element_text(size = 14),
legend.position = "bottom"
) +
labs(title = "Losses over 5 years", x = "Year", y = "Colony Losses") +
guides(color = guide_legend(title = NULL))
girafe(
ggobj = p_line,
options = list(
opts_hover(css = "stroke-width:2;"),
opts_hover_inv(css = "opacity:0.5;"),
opts_selection(type = "single", only_shiny = FALSE),
opts_tooltip(css = "font-size: 12px;")
)
)
```