Skip to contents

Documentation License: MIT

Spatially Explicit Modeling of Habitats, Trophic Webs, Dispersal, Exposure, and Ecological Risk

spacemodR is an R package designed for spatial ecological risk assessment (ERA). It integrates habitat mapping, trophic networks (food webs), animal dispersal, and contaminant exposure to build complex “spacemodels.” By linking geographic data (rasters, vectors) with biological and ecological interactions, it allows researchers and risk assessors to map the flow of elements (such as food, energy, or contaminants) across ecosystems.


🌱 The SPACEMOD Project

This package is the core computational engine of the SPACEMOD project, funded by the French ecological transition agency (ADEME) under the IMPACTS 2023 call for projects.

With the discontinuation of historical ERA software (like TerraSys or BERISP), there was a critical need for a modern, generic tool dedicated to Ecological Risk Assessment for contaminated sites and soils (SSP). The SPACEMOD project aims to fill this gap by developing a spatially explicit tool to model multi-exposures and chemical mixture impacts in trophic webs.

Project Partners: * UMR Chrono-environnement (CNRS / Université de Franche-Comté) - Project Coordinator (Pr. Renaud Scheifler) * Qonfluens SAS * UK Centre for Ecology & Hydrology (UKCEH)

You can find more information about the project on the ADEME research portal or the Chrono-environnement website.


🚀 What can you do with spacemodR?

The package provides a complete workflow to move from raw landscape data to risk indices: 1. Habitat Construction: Convert vector shapefiles (e.g., OCS-GE) into high-resolution habitat raster grids based on species-specific preferences and weights. 2. Trophic Web Modeling: Define Directed Acyclic Graphs (DAGs) representing predation and herbivory flows across the ecosystem. 3. Dispersal & Connectivity: Simulate animal movement and flow using advanced dispersal kernels or circuit theory (via integration with Julia’s Omniscape algorithm). 4. Exposure & Transfer: Calculate Daily Food Intake (DFI) and model the bioaccumulation and transfer of contaminants (e.g., Cadmium, Lead, Zinc) through the food web. 5. Risk Mapping: Generate spatially explicit risk maps (e.g., Eco-SSL indices) to identify critical hot-spots of ecotoxicological concern.


📚 Integrated Databases

To facilitate parameterization, spacemodR workflows rely on standardized ecological and physiological databases: * FmrBT: Database of Field Metabolic Rates (FMR), body mass, and ambient temperature for over 700 species (De Castro et al., 2025). * EltonTraits 1.0 / MammalBase: Functional traits and precise dietary partitioning (percentages of invertebrates, seeds, vertebrates, etc.) for birds and mammals. * GARD Initiative: Global Assessment of Reptile Distributions and traits. * TRY Plant Trait Database: Lower Calorific Value (LCV) data for plant energy density. * Add-my-pet: Dynamic energy budget models and parameters (e.g., ξWE\xi_{WE}).


📦 Installation

The package is actively developed and automatically built via GitHub Actions. Since it is not yet on CRAN, you can install it by retrieving the artifact generated by our continuous integration system, or by using Docker.

1. Via GitHub Action Artifacts (Source Installation)

The .github/workflows/build_and_release.yaml workflow checks integrity and builds the package on every push to the main branch.

  1. Go to the Actions tab of the GitHub repository.
  2. Click on the latest successful run of the “Build and Archive” workflow.
  3. Scroll to the bottom of the page to the Artifacts section and download the spacemodR-archive file.
  4. Unzip the downloaded file to extract the .tar.gz source package.
  5. Install the package in R using the following command:
# Replace the path below with the exact location of your downloaded .tar.gz file
install.packages("path/to/spacemodR_0.1.3.tar.gz", repos = NULL, type = "source")

Note: Ensure that your system dependencies (GDAL, PROJ, GEOS) are installed, as the package heavily relies on sf and terra.

2. Via Docker

A Dockerfile is provided to ensure a fully reproducible environment with all system dependencies (including Julia for Omniscape) pre-configured.

# Build the image locally
docker build -t spacemodr .

# Run the container (with RStudio Server accessible on port 8787)
docker run --rm -ti \
  -p 8787:8787 \
  -e PASSWORD=yourpassword \
  spacemodr

Note on Git LFS (For Contributors)

To track large data files (like rasters or fitted models) in the repository, we use git lfs. Before using git add on a large file, ensure it is tracked:

git lfs track "raw_data/new_fit.rda"

📄 License

spacemodR is released under the MIT License. This is a permissive free software license that allows you to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the software, provided that the original copyright notice and permission notice are included in all copies or substantial portions of the software.

See the LICENSE file for full details.