The repository containts the full working code and the repository of the input data for the advanced ecological data analysis to be held in the University of Accra, Ghana in the framework of COESSING 2025.
# Ecological & Spatial Data Analysis Lab - COESSING25
**Author**: Georgios Vagenas (MNCN, CSIC) | Predoctoral Investigador & PhD(c) at the National Spanish Research Council (CSIC)
**Project**: The Coastal Ocean Environment Summer School In Nigeria and Ghana (COESSING) - COESSING 2025
**Location**: University of Accra, Ghana (West Africa), August 2025 - Ecological Data Analysis Workshop
## 📌 Overview
This repository contains an R workflow for analyzing ecological data, estimating biomass using the BioTIME and FishBase database, and visualizing spatiotemporal patterns in species richness across the globe. The pipeline processes occurrence records, computes ecological metrics, and generates animated maps of biodiversity changes.
Link to download the layers:
saco.csic.es
## 0. Setup Working Environment
```r
# Set working directory
setwd("C:/Users/XXX/Desktop/COESSING25_Lab_Files/")
# Install required packages
install.packages(c("terra", "mapview", "dplyr", "ggplot2", "rfishbase",
"ncdf4", "gganimate", "rnaturalearth", "sf", "tidyr", "vegan"))
# Load libraries
library(terra)
library(mapview)
library(dplyr)
library(ggplot2)
library(rfishbase)
library(ncdf4)
library(gganimate)
library(rnaturalearth)
library(sf)
library(tidyr)
library(vegan)
```
## 1. Load and prepare the data
```r
md %
select(Species, a, b) %>%
mutate(a = as.numeric(a), b = as.numeric(b)) %>%
group_by(Species) %>%
summarise(a_mean = mean(a, na.rm = TRUE), b_mean = mean(b, na.rm = TRUE))
# Estimate biomass
weight_estimates %
left_join(lw_params, by = "Species") %>%
mutate(Estimated_Wmax_kg = (a_mean * (as.numeric(Lmax)^b_mean))/1000)
```
## 4. Temporal analysis
```r
# Annual landings time series
annual_landings %
mutate(biomass_kg = ABUNDANCE * weight_estimates$Estimated_Wmax_kg[match(valid_name, weight_estimates$Species)]) %>%
group_by(YEAR) %>%
summarise(total_landings_kg = sum(biomass_kg, na.rm=TRUE))
# Plot landings
landings_plot %
mutate(grid_x = round(LONGI …