Skip to content
Abson-devPublic

About

species distribution models application

Resources

Stars

5 stars

Watchers

1 watching

Forks

Repository files navigation

sdmApp sdmApp logo

R-CMD-check test-coverage lint pkgdown Codecov test coverage Lifecycle: maturing License: GPL v3 Project Status: Active minimal R version Total downloads Monthly downloads

sdmApp is an R package containing a Shiny application that lets non-expert R users model species distribution. It brings a reproducible workflow for species distribution modelling into a single, user-friendly environment. sdmApp takes raster data (in any format supported by the terra package) and species occurrence data (several formats supported) as input, and provides an interactive graphical user interface (GUI).

CRAN status

sdmApp is not currently available on CRAN. It was archived on 2024-02-10 because check problems were not corrected in time, following an earlier archival on 2021-07-06 caused by its dependency on CENFA, which had itself been archived.

Both blockers are now resolved: sdmApp no longer depends on rgdal or rgeos (retired in October 2023), and it computes the ecological-niche factor analysis itself instead of relying on CENFA. Until it is back on CRAN, install it from GitHub (see below).

Main features

  • Upload data (raster predictors and species occurrence files), or download them: occurrences from GBIF (with background points) and bioclimatic variables from WorldClim 2.1, current and CMIP6 future
  • View the correlation between raster predictors and screen collinear ones with variance inflation factors (sdmApp_vif())
  • Select species predictors with an ecological-niche factor analysis (sdmApp_enfa(), Hirzel et al. 2002), which reproduces CENFA results
  • Thin clustered occurrences to reduce sampling bias (sdmApp_thin(), the spThin algorithm), and draw background points within a buffer or in proportion to sampling effort (sdmApp_background())
  • Cross-validate on spatial blocks or environmental clusters, built with the blockCV package, to test how models transfer to new places or new conditions
  • Fit nine species distribution models (Bioclim, Domain, Mahalanobis, GLM, MaxEnt with Java or Java-free through maxnet, boosted regression trees, random forest and SVM) with random or spatial-block cross-validation, evaluated on every fold with the AUC, the true skill statistic (sdmApp_tss()) and the presence-only Boyce index (sdmApp_boyce()), and tested against null models (sdmApp_null())
  • Interpret every model and ensemble with response curves and a permutation importance of the predictors that is comparable across algorithms
  • Tune the settings of each method (regularization, complexity...) by cross-validation with sdmApp_tune()
  • Compare the fitted models side by side (sdmApp_compare()), and combine them into an ensemble weighted by their cross-validated AUC or TSS
  • Map the uncertainty of every model, ensemble and projection: the spread of the cross-validation fold models, and the disagreement between ensemble members
  • Project models and ensembles to future climates, with change and range-change maps, and flag novel conditions with a MESS map (sdmApp_mess())
  • Export results
  • Stay reproducible: the R-Code tab writes a script of every step run in the interface, which gives the same results when run in R, and an HTML report of the analysis with its results and maps
  • Script the whole workflow without the interface, with sdmApp_fit(), sdmApp_ensemble(), sdmApp_project() and friends

The GUI is built around five main windows, selectable from the navigation bar at the top of the screen. Some of these windows start empty and fill in once raster and species occurrence data have been uploaded.

Installation

System requirements

sdmApp offers MaxEnt in two versions. The original Java implementation needs a Java JDK (>= 8) and the rJava package; recent versions of dismo ship the maxent.jar file, so it no longer needs to be copied by hand. The maxnet version (Phillips et al. 2017) needs no Java.

Everything else in sdmApp works without Java.

Install the package

# install.packages("remotes")
remotes::install_github("Abson-dev/sdmApp", dependencies = TRUE)

Then launch the interface:

library(sdmApp)
sdmApp()

sdmApp() checks at launch that the modelling engines it needs are installed, and stops with a message naming any that are missing, so you never get a cryptic error halfway through a session.

Quick start without the GUI

Everything the interface does can be scripted. A full workflow on the example data:

library(sdmApp)

env <- sdmApp_read_layers(system.file("extdata",
  c("bio1.tif", "bio12.tif", "Elev.tif"),
  package = "sdmApp"
))
occ <- read.csv2(system.file("extdata", "Niakhar.csv", package = "sdmApp"))
occ <- sdmApp_occurrences(occ, "X_WGS84", "Y_WGS84", "Faidherbia.albida",
  crs = terra::crs(env)
)

# cross-validated models, evaluated with AUC, TSS and the Boyce index
glm <- sdmApp_fit(env, occ, "Faidherbia.albida", method = "glm")
rf <- sdmApp_fit(env, occ, "Faidherbia.albida", method = "rf")
sdmApp_importance(rf)

# an ensemble, projected to a warmer climate
ensemble <- sdmApp_ensemble(list(glm, rf), weight = "tss")
warmer <- env
warmer[["bio1"]] <- warmer[["bio1"]] + 2
projection <- sdmApp_project(ensemble, warmer)
projection
terra::plot(projection$range_change)

The R-Code tab of the interface writes such a script for you, with every step you ran and the same settings, so that the script reproduces your results. vignette("workflow", package = "sdmApp") walks through a complete workflow: predictor screening, spatial and environmental cross-validation, tuning, significance tests, ensembles, projections and uncertainty.

See vignette("sdmApp") for a longer walkthrough.

Example data

The package ships a small extract of the Niakhar study area in Senegal, in inst/extdata:

  • Niakhar.csv (and the same table as .xlsx, .dta, .sav, .sas7bdat), holding 9258 georeferenced trees scored for three species (Faidherbia albida, Balanites aegyptiaca and Anogeissus leiocarpus);
  • 34 raster predictors covering bioclimatic drivers, soil properties, water productivity, vegetation phenology and productivity, and watershed topography.

The bundled rasters are aligned on a common grid of 93 by 91 cells in geographic coordinates (EPSG:4326). Note that Niakhar.csv is semicolon separated and uses a comma as decimal mark, so read it with read.csv2() rather than read.csv().

The graphical interface

The five tabs are Help/About, Data Upload, Spatial Analysis, Modeling and R-Code, meant to be visited in order. To explore the app before using your own data, click "Try with example data" in the Data Upload tab. The screenshots below follow a session on Faidherbia albida in Senegal, with occurrences from GBIF and climate layers from WorldClim.

Data Upload: load your own files, or download WorldClim layers, GBIF occurrences and CMIP6 projections.

Data Upload tab

Modeling: every model is cross-validated (here on spatial blocks) and evaluated on every fold with the AUC, TSS and Boyce index.

Model evaluation

Projection: projected suitability, range change, novel conditions (MESS) and uncertainty under a future climate.

Projection and range change

Ensemble: the fitted models combined with weights from their cross-validated AUC or TSS.

Ensemble of models

R-Code: a script of every step, which reproduces the results in R.

R-Code tab

Known compatibility notes

  • blockCV 3.0 and later. spatialBlock() and spatialAutoRange() were replaced by cv_spatial() and cv_spatial_autocor(). Both the shiny interface and sdmApp_fold_Explorer() use the new interface, so blockCV (>= 3.0.0) is required; sdmApp_fold_Explorer() still accepts legacy SpatialBlock objects.
  • rgdal and rgeos. Both were archived from CRAN on 2023-10-16. sdmApp no longer depends on them; recent raster reaches GDAL, GEOS and PROJ through terra.
  • raster, terra and sp. The shiny interface works on terra rasters and sf points throughout. The exported functions accept both raster and terra objects.

Citation

citation("sdmApp")

To cite sdmApp in publications, use:

HEMA A, NDAO B, LEROUX L, DIOUF A (2026). sdmApp: A User-Friendly Application for Species Distribution Modeling. R package version 0.1.0, https://github.com/Abson-dev/sdmApp.

A BibTeX entry for LaTeX users is:

@Manual{,
  title  = {sdmApp: A User-Friendly Application for Species Distribution Modeling},
  author = {Aboubacar HEMA and Babacar NDAO and Louise LEROUX and Abdoul Aziz DIOUF},
  year   = {2026},
  note   = {R package version 0.1.0},
  url    = {https://github.com/Abson-dev/sdmApp},
}

License

sdmApp is released under the GPL-3 license.

The sdmApp sticker was made through R art kindly shared at art.djnavarro.net and released under a CC-BY-SA 4.0 license.

Guidelines for contributing

Contributions and suggestions for improving this package are welcome. Please do not hesitate to open an issue for any problem you encounter, or a pull request for any improvement you would like to propose.

References

Ndao, B., Leroux, L., Diouf, A.A., Soti, V., Sambou, B. (2019). A remote sensing based approach for optimizing sampling strategies in crop monitoring and crop yield estimation studies. In: Wade, S. (Ed.), Earth Observations and Geospatial Science in Service of Sustainable Development Goals. Springer, pp. 25-36. doi:10.1007/978-3-030-16016-6_3

Rinnan, D.S., Lawler, J. (2019). Climate-niche factor analysis: a spatial approach to quantifying species vulnerability to climate change. Ecography, 42, 1494-1503. doi:10.1111/ecog.03937

Valavi, R., Elith, J., Lahoz-Monfort, J.J., Guillera-Arroita, G. (2019). blockCV: An R package for generating spatially or environmentally separated folds for k-fold cross-validation of species distribution models. Methods in Ecology and Evolution, 10, 225-232. doi:10.1111/2041-210X.13107

About

species distribution models application

Resources

Stars

5 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages