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.
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.
Code
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;")
)
)