Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
369 commits
Select commit Hold shift + click to select a range
564c000
Increase aspect ratio of PDFs and PNGs
soriadelva Sep 3, 2025
cc50a07
Replace projectname by project to comply with configurations file in …
soriadelva Sep 3, 2025
93ad977
Load only relevant packages in script 4
soriadelva Sep 3, 2025
de15bd2
Source helper functions and configuration file
soriadelva Sep 3, 2025
26c0da5
Load country shape through rnaturalearth
soriadelva Sep 3, 2025
b6af141
Rename speciesKey to acceptedTaxonKey
soriadelva Sep 3, 2025
feee6bf
Remove transformation of euboundary
soriadelva Sep 3, 2025
aaa360f
Fix PNG Europe folder path
soriadelva Sep 3, 2025
c694af0
create folder for process scripts
DiederikStrubbe Sep 3, 2025
84b634a
Alter text
soriadelva Sep 3, 2025
16bcafb
Setup CV script
DiederikStrubbe Sep 3, 2025
e345339
Convert speciesKey to acceptedTaxonKey
soriadelva Sep 8, 2025
2019227
Start script for processing CORINE layers
soriadelva Sep 8, 2025
57682c3
Update packages in script 4
soriadelva Sep 8, 2025
3a9c3e9
Load habitat files in script 4
soriadelva Sep 8, 2025
306b8cf
Rewrite paths using here::here
soriadelva Sep 8, 2025
f62ee89
Use acceptedTaxonKey instead of speciesKey
soriadelva Sep 8, 2025
192b5d7
Use country_of_interest instead of country_name
soriadelva Sep 8, 2025
2837476
Rename datasets
soriadelva Sep 8, 2025
066e921
Select only relevant columns
soriadelva Sep 8, 2025
b8eedf8
Remove old trias workflows
soriadelva Sep 8, 2025
955cee7
Move processing scripts to processing folder
soriadelva Sep 8, 2025
c006c43
Rename configurations file
soriadelva Sep 8, 2025
58fa986
Rename script prepare_files_and_folders
soriadelva Sep 8, 2025
e055ebf
Rename scripts to clarify order
soriadelva Sep 8, 2025
bc8a6bc
Remove duplicate script
soriadelva Sep 8, 2025
2ae9717
Rename Configurations.R to 00_configurations.R
soriadelva Sep 8, 2025
6350e19
Add curlopts=list(http_version=2) to occ_download and name_backbone
soriadelva Sep 8, 2025
979ebf1
Update README.md
soriadelva Sep 8, 2025
b4ed635
Convert stop to next when no biasgrid is available, so it does not b…
soriadelva Sep 8, 2025
468ed01
Remove raw folder and store raw occs temporarily in data folder
soriadelva Sep 8, 2025
0cd8657
Add sf to sf_use_s2
soriadelva Sep 9, 2025
d8cc687
Remove mapview from packages
soriadelva Sep 9, 2025
d8a5039
Load habitat rasters and cut to common extent
soriadelva Sep 12, 2025
93820a7
Add script used to process the CORINE layers
soriadelva Sep 12, 2025
901882b
Add code to get response curves and variable importance in global model
soriadelva Sep 17, 2025
3c250e0
Add code to calculate response curves and variable importance in Euro…
soriadelva Sep 17, 2025
ad26b26
Store selected models in global and european model script
soriadelva Sep 17, 2025
7696047
Add rationale for thinning to max 10000 occurrence records in global …
soriadelva Sep 19, 2025
5dfb221
Fix ggplot error
soriadelva Sep 19, 2025
8bc93fe
Load future climate layers in global model
soriadelva Sep 19, 2025
f55e487
Create new raster folders for each future period and scenario
soriadelva Sep 19, 2025
eae0612
Clean up writing style
soriadelva Sep 19, 2025
f14dc7b
Create rasters of future predictions
soriadelva Sep 19, 2025
5b8ce9e
Save future predictions in qs file
soriadelva Sep 19, 2025
8f281ed
Add packages and package dependencies
soriadelva Sep 23, 2025
96d56f9
Create EU and global folders
soriadelva Sep 23, 2025
9817341
Prepare filenames for export
soriadelva Sep 23, 2025
b746bf8
Remove 100km buffer aroud occurrences
soriadelva Sep 23, 2025
fee427c
Remove favourability of fitted models, keep only those of ensemble
soriadelva Sep 23, 2025
ec66ad7
Update folder paths and filenames
soriadelva Sep 23, 2025
0eb823e
Update rm statement at the end of loop
soriadelva Sep 23, 2025
e15cc76
Place response curves and variable importance at the end of scripts
soriadelva Sep 23, 2025
23b9113
Rename speciesName and nameExtension
soriadelva Sep 23, 2025
8c99870
Generate maps with future predictions
soriadelva Sep 23, 2025
c7e9d99
Delete unnecessary code
soriadelva Sep 23, 2025
d8d5ba5
Use eu_occ (sf file) instead of euocc (coordinates derived from sf) f…
soriadelva Sep 23, 2025
5555345
Update exportPDF statements
soriadelva Sep 23, 2025
7cd6775
Update text
soriadelva Sep 23, 2025
411a5ee
Update mtp value
soriadelva Sep 23, 2025
740bf19
Small final fixes
soriadelva Sep 23, 2025
862bb18
Update exportPDF function
soriadelva Sep 23, 2025
4c37e04
Add TIP to not use long project name
soriadelva Sep 24, 2025
c875cb2
Set occurrence thinning method to kmeans clustering as default
soriadelva Sep 24, 2025
6d84360
Add mtp probabilities to configurations file
soriadelva Sep 24, 2025
c210e06
Replace here::here by file.path to prevent Windows error due to long …
soriadelva Sep 24, 2025
de038a9
Update folder structure in global model script
soriadelva Sep 24, 2025
e3820c7
Increase readability of script by very small changes
soriadelva Sep 24, 2025
818d141
Rewrite binary map part so it works by configuring mtp_probabilities
soriadelva Sep 24, 2025
0bd54a3
Adjust exportPDF function so it uses Current instead of Historical as…
soriadelva Sep 24, 2025
225d43c
Move response curves and variable importance part at the end of habit…
soriadelva Sep 24, 2025
ba26e36
Create test_fitglobal_model.R
soriadelva Oct 27, 2025
e9ba18f
Delete test_fitglobal_model.R
soriadelva Oct 27, 2025
c7d2432
Update description of mtp_probabilities in configurations file
soriadelva Oct 29, 2025
25441a3
Update biasgrid file names to comply with latest versions of Diederik
soriadelva Oct 29, 2025
12ec522
Add mtp_probabilities to exclusion list for final clean up
soriadelva Oct 29, 2025
5981e7e
Clean up script (add spaces, remove code that is inactive)
soriadelva Oct 29, 2025
0215f1f
Remove n_clusters from configurations file
soriadelva Oct 29, 2025
14bb493
Update remove_duplicates function
soriadelva Oct 29, 2025
393088f
Update remove_nodata_occurrences
soriadelva Oct 29, 2025
097260b
Update kmeansclustering
soriadelva Oct 29, 2025
ce0b240
Remove parts of Boyce index from global model script
soriadelva Oct 29, 2025
8826f8d
Add spaces
soriadelva Oct 29, 2025
deacd12
Calculate threshold manually based on values of ensemble model not th…
soriadelva Oct 29, 2025
7874a49
Update kmeans clustering in European model script to avoid creating d…
soriadelva Oct 29, 2025
8443d21
Remove placeholder CV script
soriadelva Oct 30, 2025
5c4a2f9
Add European crossvalidation script (UPDATE2) of Diederik
soriadelva Oct 30, 2025
86dddfe
Update text and explanations
soriadelva Nov 23, 2025
153e279
Add a line to prevent terra from writing aux.xml files
soriadelva Nov 23, 2025
73f290b
Add magick to loaded packages
soriadelva Nov 23, 2025
9aef987
Update filepaths in global model script
soriadelva Nov 23, 2025
6c347e5
Rename globalmodels as climatemodel
soriadelva Nov 23, 2025
7412506
Create RCP folders in a loop
soriadelva Nov 23, 2025
0703a68
Rename global climate as chelsa current folder
soriadelva Nov 23, 2025
6eca363
Inactivate code to download future layers from CHELSA and habitat lay…
soriadelva Nov 23, 2025
b99d90b
Mask and scale only current layer in the prepare_files_and_folders sc…
soriadelva Nov 23, 2025
b70b4fd
Remove code to create future country climate layers
soriadelva Nov 23, 2025
8216667
Create common (parts of) file names
soriadelva Nov 23, 2025
661a193
Create habitat and combined folders
soriadelva Nov 23, 2025
57dd042
Remove column species when doing kmeans clustering
soriadelva Nov 23, 2025
65c8729
Export PDFs of current habitat suitability
soriadelva Nov 23, 2025
b82447f
Create binary habitat maps in loop
soriadelva Nov 23, 2025
1751940
Remove calcultation of boyce index as it will be done in CV
soriadelva Nov 23, 2025
bbbe6c6
Export combined raster
soriadelva Nov 23, 2025
f26e9f0
Create binary maps of combined suitability
soriadelva Nov 23, 2025
fdd8824
Create future combined maps
soriadelva Nov 23, 2025
6d46548
Update export
soriadelva Nov 23, 2025
d15d79a
Remove scripts for country level predictions and evalution of indepen…
soriadelva Nov 23, 2025
76dd1ea
Add temporary script for calcultating boyce index
soriadelva Nov 23, 2025
fe01402
Update remove_duplicates function by refering to column numbers inste…
soriadelva Nov 23, 2025
71061ab
Load packages in cross validation script
soriadelva Nov 23, 2025
375fff2
Load habitat rasters, mask and scale them
soriadelva Nov 23, 2025
4a0093a
Load ecoregions
soriadelva Nov 23, 2025
3eabeb4
Load shape of Europe
soriadelva Nov 23, 2025
042a9a2
Load species data
soriadelva Nov 23, 2025
9989c43
Start loop
soriadelva Nov 23, 2025
fc25f7b
Remove code that has been placed elsewhere
soriadelva Nov 23, 2025
cc3ca53
Extract species data in loop
soriadelva Nov 23, 2025
326530c
Define species paths in loop
soriadelva Nov 23, 2025
86648a1
Load climate and habitat model in loop
soriadelva Nov 23, 2025
fb9a1b7
Import raster layers in loop
soriadelva Nov 23, 2025
609c951
Remove original code to load species data, models and rasters
soriadelva Nov 23, 2025
476f759
Remove code that ensures required packages in worker: CHECK
soriadelva Nov 23, 2025
3821fb1
Remove code that creates per-worker tempdirs (CHECK)
soriadelva Nov 23, 2025
9f5b6fb
Remove code that disables S2 and cleans up on exit (CHECK)
soriadelva Nov 23, 2025
bd62746
Remove code that forces on-disk processing (CHECK)
soriadelva Nov 23, 2025
0673344
Update text
soriadelva Nov 23, 2025
1923e89
Update text
soriadelva Nov 23, 2025
1e5dfb4
Add package dependency
soriadelva Nov 23, 2025
b194934
Add package dependencies
soriadelva Nov 23, 2025
34c1e38
Follow time during loop
soriadelva Nov 23, 2025
91bd465
Store raster in future Combined folder
soriadelva Nov 23, 2025
b49d45b
Export future combined favorability raster
soriadelva Nov 23, 2025
f6b010e
Add package dependency
soriadelva Nov 23, 2025
0cea2a8
Export favorability habitat raster
soriadelva Nov 23, 2025
4122669
Create INACTIVE_06_Make_country_level_predictions.R
soriadelva Nov 23, 2025
e72d86a
Create 06_run_wiSDM.R
soriadelva Nov 23, 2025
29afd22
Add part to configurations file where users place their GBIF credenti…
soriadelva Nov 23, 2025
2d5e167
Extract GBIF credentials from Renviron file to run script automatically
soriadelva Nov 23, 2025
18ded21
Rename global model to climate model and European model to habitat model
soriadelva Nov 23, 2025
1c22a20
Update readme
soriadelva Nov 23, 2025
1aacbf9
Update README.md
soriadelva Nov 24, 2025
f45dd74
Update README.md
soriadelva Nov 24, 2025
18f3890
Update GBIF credentials part of configurations
soriadelva Nov 24, 2025
12c496d
Add confidence map file paths
soriadelva Nov 26, 2025
9e4d6fb
Update text
soriadelva Nov 26, 2025
2aaf9c2
Create climate mean and sd ensemble files (next to median)
soriadelva Nov 26, 2025
cac4185
Export maps with ensemble SD
soriadelva Nov 26, 2025
443564b
Export maps with ensemble mean in interim folder
soriadelva Nov 26, 2025
abc67d8
Create and export maps with future SD and mean values
soriadelva Nov 26, 2025
8e744b6
Add dataType Stdev to exportPDF function
soriadelva Nov 26, 2025
19d5152
Update Readme
soriadelva Nov 26, 2025
dc64ce1
Add folders for confidence maps
soriadelva Nov 26, 2025
1252665
Rephrase biomes as ecoregions
soriadelva Nov 26, 2025
9638e63
Create habitat mean and sd layers
soriadelva Nov 26, 2025
21ee94f
Export habitat SD layer
soriadelva Nov 26, 2025
7692af7
Create map with final combined SD prediction
soriadelva Nov 26, 2025
50f0b20
Create and export future combined SD maps
soriadelva Nov 26, 2025
b8879fb
Use habitat layer as euboundary
soriadelva Nov 27, 2025
adf2699
Remove data/processed folder
soriadelva Dec 3, 2025
29a2051
Download future CHELSA layers via Zenodo API download
soriadelva Dec 3, 2025
a0b1245
Download land cover predictors via Zenodo API download
soriadelva Dec 3, 2025
d6bece3
Download biasgrids via Zenodo API download
soriadelva Dec 3, 2025
967f112
Mask future climate layers with eu_climpreds.10, which is based on ha…
soriadelva Dec 3, 2025
3a5fd07
Round MTP threshold to 2 decimals on prediction map
soriadelva Dec 3, 2025
598d1e5
Update description in Process_CORINE_layers script
soriadelva Dec 3, 2025
eacc6ab
Update export PDF function so it complies with novel extent of maps d…
soriadelva Dec 3, 2025
6e8697d
Remove PRA folder under data/external
soriadelva Dec 3, 2025
a16e912
Remove chelsa_eu_clips folder under data/external/climate
soriadelva Dec 3, 2025
f1762d7
Update .gitignore
soriadelva Dec 3, 2025
bc407c3
Delete Asclepias PNGs
soriadelva Dec 3, 2025
21348cf
rename calculate_boyce temporarily to INACTIVE_calculate_boyce
soriadelva Dec 3, 2025
1ec2e1e
Delete data/projects directory
soriadelva Dec 3, 2025
a958972
Delete data/external/GIS/Belgium_ecoregions directory
soriadelva Dec 3, 2025
ba31a7d
Update .gitignore
soriadelva Dec 3, 2025
63a6710
Merge branch '39-implement-changes-of-diederik' of https://github.com…
soriadelva Dec 3, 2025
a910985
Filter out absences during download
soriadelva Dec 4, 2025
8fe1369
Filter out geospatialissues and coordinateuncertainty above 5000m in …
soriadelva Dec 4, 2025
855696f
Update comment lines for GBIF credentials
soriadelva Dec 5, 2025
f4f5700
Update zenodo downloads
soriadelva Dec 5, 2025
cd007c9
Update README
soriadelva Dec 6, 2025
c11a0c8
Use outline of landcover grid as euboundary
soriadelva Dec 7, 2025
e78699a
Adjust euboundary filter so it takes into account EU crs
soriadelva Dec 7, 2025
c4d61b8
Add set.seed prior to running models
soriadelva Dec 8, 2025
d979a98
Add package dependencies and spaces
soriadelva Dec 9, 2025
cada91d
Perform k-means clustering for unique centers
soriadelva Dec 9, 2025
8c14fd8
Update PA selection with kmeans clustering and removal of environment…
soriadelva Dec 9, 2025
ecaf51f
Add pseudoabsence_thinning_method to configurations file
soriadelva Dec 9, 2025
d495512
Align code
soriadelva Dec 9, 2025
ae1b1f7
Align code
soriadelva Dec 9, 2025
f801db1
Perform K-means clustering for unique centers
soriadelva Dec 9, 2025
62cde79
Update pseudoabsence samplingt to not include combination of env valu…
soriadelva Dec 9, 2025
16f742f
Update final output code
soriadelva Dec 9, 2025
9726560
Wrap predict for habitat model in tryCatch, predict in two blocks if …
soriadelva Dec 9, 2025
ba71818
Update text
soriadelva Dec 9, 2025
8da1255
Update .gitignore
SanderDevisscher Dec 10, 2025
b3ba66d
drop `/Soria`
SanderDevisscher Dec 10, 2025
4dccf82
initial setup
SanderDevisscher Dec 10, 2025
e0d6a45
Update helper_functions.R
SanderDevisscher Dec 10, 2025
b3d5120
first implementation & tests
SanderDevisscher Dec 10, 2025
ca52390
some more implementation
SanderDevisscher Dec 10, 2025
e872228
add logic to cope with a list of files
SanderDevisscher Dec 10, 2025
e05ae29
some more implementation
SanderDevisscher Dec 10, 2025
6d41529
finish implementation
SanderDevisscher Dec 10, 2025
e1ecab4
tony tweaks
SanderDevisscher Dec 10, 2025
9101183
move chelsa_mask to outside
SanderDevisscher Dec 10, 2025
a437933
Update README.md
soriadelva Dec 11, 2025
17c6ff8
Add askyesno for scaling current environmental layer
soriadelva Dec 11, 2025
1397687
Only show basename of raster file to be downloaded
soriadelva Dec 11, 2025
848263c
Merge pull request #44 from trias-project/improve-01_prepare_files_an…
SanderDevisscher Dec 11, 2025
feaebd0
Fix clean up
soriadelva Dec 12, 2025
0047255
Convert scenario = Current to period = Current
soriadelva Dec 12, 2025
651db05
Set scenario to "" if period is Current
soriadelva Dec 12, 2025
b8777e9
skip download when nothing to download
SanderDevisscher Dec 12, 2025
e0c6237
Update askyesno rationale for scaling current CHELSA layers
soriadelva Jan 26, 2026
fca8398
Add filtering steps from climate script to occurrence download script
soriadelva Jan 26, 2026
a5f32f6
Inactivate that taxa need to be species in occurrence download script
soriadelva Jan 26, 2026
c4b6b76
Add terra as last package and update terra options
soriadelva Jan 26, 2026
0c66328
Remove occurrence cleaning from climate script
soriadelva Jan 26, 2026
3e8da0a
Write spatrasters locally and store filepaths
soriadelva Jan 26, 2026
a6ba674
Load rasters within loop
soriadelva Jan 26, 2026
8f7849a
Select pseudoabsences using 5k grid and delete part where rows are re…
soriadelva Jan 26, 2026
0f7b116
Load rasters within loop
soriadelva Jan 26, 2026
a25b3d8
aggregate rasters to 2k for PCAm method as it is computationally to h…
soriadelva Jan 26, 2026
8401105
Create predictions in blocks and merge blocks to prevent errors in ma…
soriadelva Jan 26, 2026
4b9a1d7
Update text and load fav_stack more efficiently
soriadelva Jan 26, 2026
a63113a
Create predictions for region of interest instead of whole of Europe
soriadelva Jan 26, 2026
004ac6b
Add workflow parameter (INACTIVE) to configurations file
soriadelva Jan 26, 2026
b08dbe7
Put terra as last package to load
soriadelva Jan 26, 2026
72ef384
Store habitat layers locally and load euboundary and country boundary
soriadelva Jan 26, 2026
7aedd6e
Load habitat rasters within loop
soriadelva Jan 26, 2026
d1bc04b
Delete part where pseudoabsences with same environmental variables as…
soriadelva Jan 26, 2026
7e6cec8
Make predictions in blocks to prevent errors with maxent
soriadelva Jan 26, 2026
1878e74
Inactivate part that checks how many algorithms worked (check later!)
soriadelva Jan 26, 2026
896ddf9
Create predictions at country level
soriadelva Jan 26, 2026
3e0d769
Update removal statement at the end
soriadelva Jan 26, 2026
24f6c40
Update df in download occurrences
soriadelva Jan 26, 2026
cb96817
Update update_files_logic to use "ask", "yes", "no"
soriadelva Jan 27, 2026
5018cdb
Add stringr and remotes to packages to load and load qs as tarball
soriadelva Jan 27, 2026
b265359
Set update files to lower
soriadelva Jan 28, 2026
e75a357
add safe_download_zenodo
SanderDevisscher Jan 29, 2026
9826a90
use safe_download_zenodo
SanderDevisscher Jan 29, 2026
c91f398
improve qs installation logic
SanderDevisscher Jan 29, 2026
a8a9984
Add rJava to packages to be installed
soriadelva Feb 17, 2026
5b93d4e
Merge branch '39-implement-changes-of-diederik' of https://github.com…
soriadelva Feb 17, 2026
ad614d7
Allow wiSDM to run for Europe without problem, following the implemen…
soriadelva Feb 18, 2026
876c972
Add helper function read or redownload
soriadelva Feb 19, 2026
b3523d5
Add read or redownload rationale to prepare files and folders script
soriadelva Feb 19, 2026
2cc27ae
Keep country_of_interest at end of modelling flow and don't load rJav…
soriadelva Feb 20, 2026
a772bad
add gc() in pdf helper function
soriadelva Feb 20, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,11 @@ rsconnect/
.Rproj.user

#ignore data inputs (too big for github, downloadable on Zenodo)
data/raw/
data/processed/sdm_occ_pts/
data/processed/geotiffs/
data/processed/general/
data/external/bias_grids/
data/external/climate/
data/external/data_cube/
data/external/GIS/
data/external/GIS/Country/
data/external/GIS/Europe/
data/external/GIS/Belgium_ecoregions/
data/external/habitat/
data/external/PRA/PRA_Birds/
data/external/PRA/PRA_mammals/
data/external/PRA/PRA_molluscs/
data/external/PRA/PRA_Plants/
data/projects/
.renviron
65 changes: 45 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Alien species risk modelling and mapping

This repository contains the framework and R code for predicting the distribution of alien species throughout Belgium and greater Europe at 1 km<sup>2</sup> resolution as part of the TrIAS project.
This repository contains the framework and R code for predicting the distribution of alien species in Europe at 5 km<sup>2</sup> (climate model) and 1 km<sup>2</sup> resolution (habitat/land cover model) as part of the TrIAS project.
<br>

## Repo structure
Expand All @@ -12,7 +12,7 @@ This repository contains the framework and R code for predicting the distributio
├── .gitignore : Files and directories to be ignored by git
├── data
│ ├── external : external files required to run the model. The majority of these files will be downloaded and stored in the right folders by running script 00_prepare_files_and_folders.R.
│ ├── external : external files required to run the model. The majority of these files will be downloaded and stored in the right folders by running script 01_prepare_files_and_folders.R.
└── src : R Code
Expand All @@ -21,37 +21,62 @@ This repository contains the framework and R code for predicting the distributio

## Requirements to run this workflow
1. **RStudio** installed on your local computer.
2. Have an active **GBIF account**. In script 01, you will need to enter your GBIF username, password, and email address to enable the species occurrence data download.
2. Have an active **GBIF account**. Before running the workflow for the first time, store your GBIF username, password, and email address in your `~/.Renviron` file as instructed in the script 00_configurations.R.
3. **Clone this repository** to your local computer.
4. Provide a **project name** and the **name(s) of the study species** in the respective scripts.
4. Set your specific configurations for the workflow in the **00_configurations** script (see below).
<br>

## Prior to running the workflow

Before you execute this workflow, specify the following configurations in the **00_configurations script**, which is stored in the `src` folder:

* **project**: The name of your project. A folder with this name will be created automatically in the `./data/projects` folder, and all workflow outputs will be stored there.

* **species_to_model**: Specify the species you want to model as a character string (e.g., `"Vespa velutina"`). Multiple species can be provided as a character vector (e.g., `c("Vespa velutina", "Aedes albopictus")`). Use Latin binomials only (no authorship or year).

* **occurrence_thinning_method**: When a species has more than 10000 occurrences, records are thinned to 10000 to match the number of pseudoabsences. Options:<ul>
<li><code>"random"</code>: randomly samples 10000 occurrences.</li>
<li><code>"kmeans_clustering"</code>: performs k-means clustering in environmental space and selects 10000 cluster centroids, ensuring the thinned occurrences represent the broadest environmental variation.</li>
</ul>

* **mtp_probabilities**: Defines the minimum training presence (MTP) thresholds used to convert continuous favorability predictions into binary presence/absence maps. For each value in `mtp_probabilities`, the workflow removes the lowest *x*% of occurrence probabilities and uses the next-lowest value as the threshold. Example: `mtp_probabilities = c(0.01, 0.05)` will produce binarized maps where the threshold corresponds to the lowest favorability that remains after the 1% and 5% lowest-favorability occurrences are removed.

* **country_of_interest**: Currently inactive, do not modify this parameter. The workflow currently produces predictions only for the whole of Europe. Future versions will allow masking outputs to a user-defined country.

* **update_files**: Whether or not all needed raster input files should be downloaded again. Options are *"ASK"*: the user will be prompted if a specific file should be downloaded again (any missing files are downloaded by default), *TRUE*: all files are downloaded again and *FALSE*: only missing files are downloaded

## Executing the workflow

To execute this workflow, run the following scripts (stored in the `src` folder) in the designated order:

0. **Script 00_prepare_files_and_folders**: Sets up the folder structure and downloads the files (climate rasters, habitat predictors, spatial boundaries,...) necessary to run the workflow.
1. **Script 01_global_occurrence_download.R**: After specifying the name of your project and your species of interest, this script creates a project folder on your local computer and retrieves occurrence data for the respective species from the Global Biodiversity Information Facility (GBIF). To allow this data download, a pop-up will appear, requesting you to enter your GBIF username, password, and email address.
2. **Script 02_fit_global_model.R**: Builds a global-scale climate-only species distribution model (SDM) for each species specified in script 01. Ensure you use the same project name as in the former script.
3. **Script 03_fit_European_model.R**: Generates European-level SDMs for the specified species. Again, use the same project name as in script 01.
4. **Script 04_Make_country_level_predictions.R**: Predicts species distributions and generates confidence maps under different climate change scenarios (RCP 2.6, RCP 4.5, and RCP 8.5) for a country or region of interest. At the moment, the workflow is only operational for Belgium, but this will be adjusted soon to incorporate more countries.
To execute this workflow, run the **06_run_wiSDM.R** script, stored in the `src` folder. This script automatically runs the following scripts in the designated order:

0. **Script 00_configurations**: Specifies the workflow's configurations (e.g., project name, species to model, thinning method, MTP threshold settings). IMPORTANT: users must actively set these fields themselves prior to running the workflow.
1. **Script 01_prepare_files_and_folders**: Sets up the folder structure and downloads the files (climate rasters, habitat predictors, spatial boundaries,...) necessary to run the workflow.
2. **Script 02_global_occurrence_download.R**: Retrieves occurrence data for the species of interest defined in script 00 from the Global Biodiversity Information Facility (GBIF).
3. **Script 03_fit_climate_model.R**: Builds a global-scale climate-only species distribution model (SDM) for each species of interest, at a resolution of 5 km<sup>2</sup>. The results of this model are presented at the level of Europe and can be found in the folder `./data/projects/<your project>/species/Climate`.
4. **Script 04_fit_habitat_model.R**: Generates a European-scale habitat-only species distribution model for the specified species at a resolution of 1 km<sup>2</sup> and integrates these predictions with the 5 km² climate-only predictions from script 03. The two prediction layers are integrated by using the geometric mean to generate a final suitability map at 1 km<sup>2</sup> resolution that reflects both climate suitability and habitat (land cover) suitability. Final predictions are generated for both current conditions and for two future periods, 2041-2070 and 2071-2100, under different climate change scenarios (SSP1-2.6, SSP3-7.0, and SSP5-8.5). The results of the habitat model can be found in the folder `./data/projects/<your project>/species/Habitat`, while the final predictions, combining both the habitat and the climate suitability, can be found in the `./data/projects/<your project>/species/Combined` folder.
<br>

## What does the Trias modeling workflow do?
1. Automatically generates habitat suitability maps using machine learning.
Our workflow requires only a species name and generates an ensemble of machine learning algorithms stacked together as a meta-model to produce the final habitat suitability map at 1 km<sup>2</sup> resolution. Maps are generated automatically for standard IPCC greenhouse gas emission scenarios (RCP's 2.6, 4.5, and 8.5).
2. Automatically generates confidence maps for each habitat suitability map. These illustrate confidence of each individual prediction across your study extent.
3. Addresses geographic sampling bias
4. Incorporates best practices for the placement of pseudo-absences: pseudo absences are placed in the same ecoregions where presences occur. We use the global model to restrict pseudo-absences to areas of low predicted suitability. We use the taxonomic occurrence grid (aka bias grid) to not place pseudoabsences in areas of low sampling effort. The taxonomic occurrence grid summarizes the sampling effort of the higher taxon the modelled species belongs to.
5. Detects and removes highly correlated predictors. Highly correlated predictors can have undesirable effects and confuse the interpretation of variable importance
6. Integrates multiple machine learning algorithms to predict habitat suitabilities. It has been consistently demonstrated that the choice of algorithm has the largest impact on predicted suitability.
7. Assesses spatial autocorrelation in the residuals to assess the impacts of clustering. If high, we recommend the employment of thinning.
## What does the TrIAS modelling workflow do?
1. **Generates habitat suitability maps using machine learning.**
The workflow requires only a species name and then fits an ensemble of ten machine-learning algorithms to estimate both climate suitability (using global occurrences) and habitat suitability (using European occurrences). For each type (habitat and climate), the favourability maps from all ten algorithms are first stacked and analysed using Principal Component Analysis (PCA). For each algorithm, the spatial variance of its predictions projected onto the first principal component (PC1) is calculated. The five algorithms with the highest variance along PC1, representing those that contribute most strongly to the dominant pattern of variation across the study area, are then used to generate the final suitability map. These two maps (one for the climate model and one for the habitat model) are then combined using the geometric mean in order to produce a final overall suitability prediction. All maps are generated automatically for current conditions, and climate suitability maps, along with the final combined maps, are also produced for three standard Shared Socioeconomic Pathways (SSP1-2.6, SSP3-7.0, and SSP5-8.5) for the periods 2041–2070 and 2071–2100.
2. **Implements best practices for pseudoabsence placement:**
* **Climate model**: Pseudoabsences are sampled within the same biomes as species presences but excluded from presence grid cells. A taxonomic sampling effort grid (bias grid) captures the sampling intensity of the higher taxon and is used to weight grid cells, assigning greater weight to well-sampled areas.
* **Habitat model**: Pseudoabsences are sampled across all of Europe, excluding presence grid cells. In ecoregions with presences, grid cells are weighted using the bias grid, while outside these ecoregions all cells are assigned the minimum weight (1).
3. **Detects and removes highly correlated predictors.**<br>
Highly correlated predictors can have undesirable effects and confuse the interpretation of variable importance.
4. **Automatic generation of confidence maps** for each suitability map. These maps illustrate prediction uncertainty across the study area by calculating the population standard deviation of the predictions produced by the five algorithms for both the climate and habitat models. The standard deviation of the combined prediction is then computed using the appropriate error-propagation formula for the geometric mean. Note that the standard deviation is always calculated from the mean of the five algorithms, whereas the final suitability predictions are based on their median. Consequently, the confidence maps provide a relative measure of model uncertainty but should not be interpreted as the uncertainty of the median prediction itself.
<br>

## Future functionalities
1. **Evaluation of spatial autocorrelation** in model residuals to detect clustering effects. If autocorrelation is high, the workflow will recommend (but not automatically apply) occurrence thinning.
2. **Cross-validated Boyce Index calculation** to provide a robust, presence-only model performance measure.
<br>

## Contributors

[List of contributors](https://github.com/trias-project/risk-modelling-and-mapping/contributors)
<br>

## License

[MIT License](https://github.com/trias-project/risk-modelling-and-mapping/blob/master/LICENSE)
Binary file not shown.
1 change: 0 additions & 1 deletion data/external/GIS/Belgium_ecoregions/EcoregiosBelgium.prj

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading