Written and maintained by CASRAI Editorial Board
Published
On this page
The dismo package in R is a foundational computational framework for species distribution modeling (SDM) and ecological niche modeling, providing researchers with specialized tools to predict geographic distributions, analyze bioclimatic envelopes, interface with the Maximum Entropy (MaxEnt) algorithm, and perform robust spatial cross-validation and evaluation across environmental gradients.
Definition and Scope of the dismo Package
Developed and maintained by Robert J. Hijmans alongside co-authors Steven Phillips, John Leathwick, and Jane Elith, dismo (short for Distribution Modeling) is hosted on the Comprehensive R Archive Network (CRAN) under the GPL-3 open-source license. The package bridges observational biodiversity informatics and spatial environmental data, allowing quantitative ecologists to establish statistical and machine learning relationships between georeferenced species records and gridded environmental predictors.
Species distribution modeling—alternatively designated environmental niche modeling (ENM), habitat suitability modeling, or climate-envelope modeling—predicts the probability of species occurrence or relative habitat suitability across a designated geographical landscape. In quantitative ecology, forestry, and conservation biogeography, researchers use these models to quantify species-environment relationships, map potential habitats for rare or threatened taxa, predict biological invasion pathways, evaluate biodiversity shifts under global climate change scenarios, and delineate spatial conservation priorities.
Within the broader scientific computing landscape, dismo occupies a central position by synthesizing multiple algorithmic paradigms under a unified interface. While general-purpose statistical packages provide standard regression routines and machine learning libraries offer classification algorithms, dismo provides tailored spatial data handling, spatial background sampling, presence-only profile modeling, threshold selection, and receiver operating characteristic evaluation designed specifically for ecological data structures. As part of modern R computational ecology workflows, dismo interfaces closely with spatial raster engines—historically the raster and sp packages and increasingly the modern terra framework—to streamline reproducible ecological forecasting.
Core Architecture and Operational Workflow in dismo
The standard species distribution modeling pipeline in dismo consists of five interconnected analytical stages: observational data acquisition and preprocessing, environmental predictor grid assembly, background or pseudo-absence point generation, model calibration, and quantitative spatial prediction and validation.
In field ecology and biological research, species occurrence records typically originate from targeted scientific surveys, preserved museum and herbarium specimens, or open-access biodiversity aggregators such as the Global Biodiversity Information Facility (GBIF). The dismo package directly facilitates raw data retrieval through its built-in gbif() query function, which interfaces with web APIs to extract georeferenced latitude-longitude coordinates, taxonomic identifiers, and collection metadata. However, raw biodiversity databases frequently exhibit severe spatial and geographic sampling biases, coordinate inaccuracies, duplicate occurrences, and misidentified localities that must be systematically curated before calibration.
Environmental data layers—typically consisting of macroclimatic grids (such as WorldClim or CHELSA temperature and precipitation bioclimatic variables), topographic indices (elevation, slope, aspect, topographic wetness), edaphic soil profiles, and satellite remote sensing vegetation layers—are assembled as raster stacks. The dismo package extracts environmental covariates across geographic point coordinates using raster extraction routines, matching each biological observation with its corresponding multi-dimensional environmental attributes.
Because many biological datasets consist exclusively of presence-only records without verified absences, dismo implements specialized spatial sampling algorithms. The randomPoints() function generates pseudo-absence or environmental background locations across the study extent, allowing presence-background modeling engines like MaxEnt and generalized additive models to sample the background environmental distribution against which occurrence points are contrasted.
Species Distribution Modeling Algorithms in dismo
The dismo package categorizes distribution modeling engines into three fundamental methodological classes: presence-only profile (envelope) methods, presence-background machine learning algorithms, and presence-absence regression models. Each method carries specific mathematical assumptions, data requirements, and spatial projection properties.
Profile and Envelope Methods
Profile methods rely strictly on presence records, assessing the environmental characteristics of occupied sites without requiring background sampling or true absences. These methods are computationally rapid and transparent, though they do not estimate absolute occurrence probabilities:
- BIOCLIM (
bioclim): The historic bioclimatic envelope algorithm originally developed by Busby (1991). BIOCLIM computes the multi-dimensional frequency distribution and percentile envelopes (such as the 5th to 95th percentiles) of environmental attributes at known presence sites. A site’s suitability score reflects its proximity to the median environmental value across all measured predictors, assigning a score of zero to any location outside the observed environmental envelope. - DOMAIN (
domain): Introduced by Carpenter et al. (1993), DOMAIN computes point-to-point Gower distance metrics between candidate spatial locations and known presence localities. By normalizing environmental attributes by their observed ranges, DOMAIN assigns a continuous similarity score between 0 and 1, providing smooth suitability surfaces even in complex topographies. - Mahalanobis Distance (
mahal): Calibrates ecological distance based on the multivariate mean and covariance matrix of environmental variables at presence points. Mahalanobis distance explicitly accounts for correlations among climatic layers, measuring how many standard deviations a candidate cell lies from the centroid of the species’ environmental niche.
Machine Learning Algorithms: MaxEnt and Boosted Regression Trees
Machine learning frameworks implemented in dismo consistently achieve superior predictive accuracy in comparative ecological evaluations, particularly when modeling complex non-linear ecological response curves and high-order environmental interactions:
- Maximum Entropy (
maxent): Developed by Phillips, Anderson, and Schapire (2006) and statistically formalized by Elith et al. (2011), MaxEnt estimates the probability distribution of maximum entropy (closest to uniform) subject to empirical constraints. These constraints dictate that the expected value of each environmental feature (linear, quadratic, product, threshold, and hinge features) under the estimated distribution must match its empirical average across observed presence points. In dismo,maxent()acts as an automated R wrapper around the standalone Java programmaxent.jar(via therJavapackage), enabling programmatic tuning of regularization multipliers and feature classes. - Boosted Regression Trees (
gbm.step): Synthesized by Elith, Leathwick, and Hastie (2008), Boosted Regression Trees (BRT) combine decision tree algorithms with gradient boosting. Rather than fitting a single complex tree, BRT iteratively fits hundreds or thousands of simple decision trees, with each new tree minimizing the residual error of the preceding ensemble. Functions such asgbm.step(),gbm.plot(), andgbm.simplify()automate cross-validation to determine optimal tree counts, visualize partial dependence response curves, and eliminate non-informative predictors.
Regression Frameworks and Community Ecology Integration
In addition to specialized envelope and machine learning algorithms, dismo seamlessly integrates with standard Generalized Linear Models (glm) and Generalized Additive Models (gam). When coupled with biodiversity indices from packages such as the vegan R package for community ordination or generalized linear mixed models via glmmTMB for hierarchical nested survey designs, dismo allows ecologists to examine macroecological species turnover alongside individual environmental niches.
Algorithm Selection and Methodological Comparison
Choosing the appropriate modeling algorithm within dismo depends on sample size, availability of genuine absence records, collinearity among environmental variables, and the intended application (interpolating current distributions versus projecting into novel climate spaces). The decision matrix below summarizes operational requirements across dismo’s primary engines based on published comparative benchmarks:
| Modeling Method | Data Requirements | Sample Size Sensitivity | Extrapolation Behavior | Key Strength | Primary Limitation |
|---|---|---|---|---|---|
| BIOCLIM | Presence-only (no background) | Stable with small samples (≥ 20 points) | Truncates outside observed limits (zero suitability) | Intuitive climatic limits, zero risk of runaway extrapolation | Overly conservative; ignores interactions and correlational structure |
| DOMAIN | Presence-only (no background) | Moderate sensitivity (≥ 30 points) | Smooth decay away from known points | Handles moderate sample sizes without background sampling | Sensitive to isolated coordinate outliers; no statistical hypothesis testing |
| Mahalanobis Distance | Presence-only (no background) | Requires N > number of environmental layers | Assumes multivariate elliptical symmetry | Explicitly accounts for environmental covariance | Poor performance if environmental relationships are asymmetric or bimodal |
| MaxEnt | Presence-background | Highly robust across sample sizes (15 to 10,000+ points) | Clamping prevents extreme extrapolation; MESS identifies novel space | Superior predictive accuracy; fits complex non-linear feature constraints | Requires external Java setup; susceptible to sampling bias in background selection |
| Boosted Regression Trees (BRT) | Presence-absence or weighted pseudo-absence | Requires moderate to large samples (≥ 100 points) | Tree step functions can produce plateau artifacts beyond data range | Captures high-order interactions and non-linearities automatically | Risk of severe overfitting if learning rate or bag fraction is improperly configured |
| Geographic Distance Null | Spatial coordinates only | Functional with any sample size | Decays strictly with Euclidean or spherical distance | Provides an objective geographic baseline to evaluate environmental model gain | Ignores all environmental variation; purely spatial interpolation |
The comparative data table below summarizes key computational properties, algorithmic formulas, and dependency requirements across all dismo modeling functions.
Step-by-Step Modeling Walkthrough in R
To demonstrate the operational syntax and workflow of dismo, the following walkthrough steps through data loading, spatial background generation, cross-validation partitioning, model fitting, and validation using the bundled Bradypus variegatus (brown-throated three-toed sloth) ecological dataset and WorldClim environmental grids.
1. Data Loading and Environmental Layer Ingestion
Before fitting models, environmental predictor grids and georeferenced presence points must be imported into the R workspace. The dismo package includes sample bioclimatic raster grids and South American sloth occurrences:
# Load the dismo library and spatial dependencies
library(dismo)
library(raster)
# Locate and import bundled environmental raster predictors
env_path <- system.file("ex", package = "dismo")
raster_files <- list.files(path = env_path, pattern = ".grd$", full.names = TRUE)
predictors <- stack(raster_files)
# Read species presence coordinates
points_file <- paste0(env_path, "/bradypus.csv")
bradypus_raw <- read.csv(points_file)
# Retain only geographic longitude and latitude columns
presence_coords <- bradypus_raw[, c("lon", "lat")]
2. Background Point Generation with randomPoints
For presence-background algorithms like MaxEnt, researchers must draw representative background points from the study area. Using randomPoints(), background coordinates are sampled across non-missing raster cells, optionally constrained by spatial masks or minimum distance buffers:
# Set pseudo-random seed for computational reproducibility
set.seed(42)
# Generate 1,000 random background points within the predictor extent
background_coords <- randomPoints(mask = predictors[[1]], n = 1000, p = presence_coords)
3. K-Fold Cross-Validation Partitioning
To evaluate predictive performance objectively without training on the testing data, the dataset is partitioned into five distinct cross-validation folds using kfold():
# Partition presence records and background samples into 5 folds
k_presence <- kfold(presence_coords, k = 5)
k_background <- kfold(background_coords, k = 5)
# Separate training data (folds 2 to 5) and testing data (fold 1)
train_presence <- presence_coords[k_presence != 1, ]
test_presence <- presence_coords[k_presence == 1, ]
train_background <- background_coords[k_background != 1, ]
test_background <- background_coords[k_background == 1, ]
4. Model Calibration: BIOCLIM and MaxEnt
Fitting envelope and machine learning models in dismo follows a standardized syntax. For BIOCLIM, the model fits directly to training coordinates and environmental rasters. For MaxEnt, Java integration enables full feature regularized modeling:
# Fit BIOCLIM model on training presences
bioclim_model <- bioclim(predictors, train_presence)
# Project continuous environmental suitability across the entire landscape
bioclim_prediction <- predict(predictors, bioclim_model)
# If rJava and maxent.jar are configured, fit MaxEnt model:
# maxent_model <- maxent(predictors, train_presence, a = train_background)
# maxent_prediction <- predict(predictors, maxent_model)
5. Quantitative Model Evaluation and Threshold Determination
Model performance is quantified using the evaluate() function, which compares predicted suitability scores at independent test presences against predictions at test background points. The resulting evaluation object provides threshold metrics and discrimination indices:
# Evaluate model discrimination on testing presence and background samples
eval_bioclim <- evaluate(p = test_presence, a = test_background, model = bioclim_model, x = predictors)
# Extract Area Under the ROC Curve (AUC)
print(paste("BIOCLIM Test AUC:", round(eval_bioclim@auc, 3)))
# Determine optimal threshold criteria for converting suitability to binary presence/absence
thresholds <- threshold(eval_bioclim)
print(thresholds)
# Optimal cutoffs include:
# - equal_sens_spec: balances sensitivity and specificity
# - max_sens_spec: maximizes the sum of sensitivity and specificity (Youden's J statistic)
# - no_omission: lowest predicted value across all observed presences
Where dismo Matters in Forestry, Ecology, and Environmental Decisions
The practical application of dismo extends far beyond theoretical ecology into applied natural resource management, forestry planning, biosecurity, and international conservation frameworks.
Forest Management and Silvicultural Provenance Selection
In forestry and arboriculture, commercial timber species and native canopy trees face unprecedented stress from shifting precipitation regimes, prolonged summer droughts, and novel pest outbreaks. Forest researchers deploy dismo models to evaluate the climatic envelopes of primary timber taxa (such as Pinus taeda, Pseudotsuga menziesii, and Quercus species). By projecting calibrated models onto future climate scenarios (such as CMIP6 climate projections), foresters identify vulnerable stands requiring assisted migration or select resilient seed provenances adapted to anticipated climatic trajectories.
Invasive Species Risk Assessment and Biosecurity Protocols
Agricultural biosecurity laboratories and government quarantine agencies utilize dismo to map invasion pathways for non-native insects, pathogen vectors, and agricultural weeds. By fitting niche models based on native range occurrences, analysts project potential environmental suitability across importing regions. These habitat suitability surfaces directly inform field surveillance priorities, trap placement density, and quarantine inspection protocols at shipping ports and international cargo terminals.
Conservation Delineation and Protected Area Network Design
Conservation biologists combine dismo predictions with regional biodiversity inventories—such as species richness estimates derived from iNEXT biodiversity rarefaction workflows—to identify critical ecological corridors and design climate-resilient protected area networks. Where development projects threaten endangered flora or fauna, regulatory agencies rely on standardized species distribution models to delineate legally protected core habitats and formulate mitigation strategies.
Diagnostic Checks, Environmental Extrapolation, and Common Mistakes
Despite dismo’s robust software architecture, ecological modeling errors frequently arise from improper data preparation, misconfigured software dependencies, or uncritical interpretation of spatial metrics. Practitioners should address several critical failure modes:
1. Java Environment and maxent.jar Path Misconfiguration
The most frequent technical issue encountered in dismo arises when calling maxent(). Because MaxEnt is an external Java application, R requires both a 64-bit Java Runtime Environment (JRE ≥ 8) matching the R architecture and the rJava package. Furthermore, the executable file maxent.jar must be manually downloaded from the American Museum of Natural History or GitHub repository and placed directly into the java directory of the installed dismo package (accessible via system.file("java", package = "dismo")). If the JAR file is missing, dismo throws an explicit error indicating that MaxEnt cannot be found.
2. Spatial Autocorrelation and Geographic Bias
Standard random cross-validation using kfold() can severely inflate evaluation metrics like AUC if spatial autocorrelation is present. When training and testing points are geographically proximate, spatial autocorrelation causes the model to predict spatial proximity rather than genuine environmental niche affinity. Ecologists should implement spatial or environmental block cross-validation (using geographic coordinates or environmental cluster grids) to ensure that testing folds represent independent geographic regions.
3. Detecting Novel Climates with MESS (Multivariate Environmental Similarity Surfaces)
When projecting models to future climate periods or novel geographic regions, environmental variables may take on values outside the range observed in the calibration dataset. Projecting machine learning models into non-analog novel climates often leads to unpredictable extrapolation artifacts. The dismo package includes the mess() function to compute Multivariate Environmental Similarity Surfaces. A negative MESS score indicates that at least one environmental covariate at that cell falls outside the calibration envelope, alerting researchers to interpret predictions with extreme caution.
4. Transitioning Between raster and terra Spatial Packages
Historical versions of dismo were built exclusively around the raster and sp packages. In modern R environments, spatial data analysis is largely governed by the faster C++-backed terra package. While dismo functions accept terra SpatRaster objects across many functions, certain internal operations (like legacy raster stack predictions) still expect RasterStack or RasterLayer S4 objects. Researchers working with terra can seamlessly convert objects using raster::stack(terra_object) or extract coordinates into standard data frames to avoid S4 class incompatibility errors.
Frequently asked questions
What is the dismo package in R used for?
The dismo package is an R library dedicated to species distribution modeling, environmental niche modeling, and habitat suitability mapping. It provides quantitative functions to clean occurrence data, generate background samples, fit climate-envelope and machine learning models (including BIOCLIM, DOMAIN, Mahalanobis distance, and MaxEnt), project predictions onto geographic raster grids, and evaluate model accuracy through spatial cross-validation.
How do I set up and run MaxEnt inside dismo?
To run MaxEnt within dismo, you must have Java (version 8 or higher) installed on your system along with the rJava package in R. You must download the standalone file maxent.jar and place it inside the java folder of your dismo installation, which can be located using the command system.file(‘java’, package = ‘dismo’). Once installed, calling maxent(predictors, presence_points, background_points) fits the model directly from R.
What is the difference between BIOCLIM and MaxEnt in dismo?
BIOCLIM is a classical presence-only envelope model that determines suitability based on percentile ranges of environmental variables at observed presence sites, without requiring background points or absences. In contrast, MaxEnt is a machine learning algorithm that estimates a probability distribution of maximum entropy by contrasting presence records against a background sample of environmental conditions, allowing for complex non-linear responses and higher predictive accuracy.
How does dismo evaluate species distribution models?
Model evaluation in dismo is primarily performed using the evaluate() function, which compares model suitability predictions at presence sites against predictions at absence or background sites. It calculates standard discrimination metrics including the Area Under the Receiver Operating Characteristic Curve (AUC), Cohen’s Kappa, True Skill Statistic (TSS), sensitivity, and specificity, while also computing threshold criteria to convert continuous suitability maps into binary presence/absence rasters.
Why is random background point selection necessary in dismo?
Many ecological records are presence-only data derived from opportunistic biological surveys where true absences were never recorded. Algorithms like MaxEnt and generalized linear models require a characterization of the available background environment to determine whether a species occupies certain environmental conditions disproportionately relative to what is available across the geographic landscape. The randomPoints() function provides this background sample.
Sources
- Comprehensive R Archive Network (CRAN). (2024). Package ‘dismo’: Species Distribution Modeling (Version 1.3-16). https://CRAN.R-project.org/package=dismo (Accessed 2026-11-14).
- Hijmans, R. J., & Elith, J. (2017). Species distribution modeling with R. R Spatial Documentation. https://rspatial.org/raster/sdm/ (Accessed 2026-11-14).
- Phillips, S. J., Anderson, R. P., & Schapire, R. E. (2006). Maximum entropy modeling of species geographic distributions. Ecological Modelling, 190(3-4), 231-259. https://doi.org/10.1016/j.ecolmodel.2005.03.026 (Accessed 2026-11-14).
- Elith, J., Phillips, S. J., Hastie, T., Dudík, M., Chee, Y. E., & Yates, C. J. (2011). A statistical explanation of MaxEnt for ecologists. Diversity and Distributions, 17(1), 43-57. https://doi.org/10.1111/j.1472-4642.2010.00725.x (Accessed 2026-11-14).
- Elith, J., Leathwick, J. R., & Hastie, T. (2008). A working guide to boosted regression trees. Journal of Animal Ecology, 77(4), 802-813. https://doi.org/10.1111/j.1365-2656.2008.01390.x (Accessed 2026-11-14).
- Carpenter, G., Gillison, A. N., & Winter, J. (1993). DOMAIN: a flexible modelling procedure for mapping potential distributions of plants and animals. Biodiversity and Conservation, 2(6), 667-680. https://doi.org/10.1007/BF00056679 (Accessed 2026-11-14).
Data: Comparative Specifications of Species Distribution Modeling Algorithms in the dismo R Package
Systematic comparison of the primary species distribution modeling algorithms supported by the dismo R package, compiled from the CRAN package specification (version 1.3-16), rspatial.org documentation, and foundational literature by Elith et al. Columns summarize model category, primary function syntax, input data requirements (presence-only, presence-background, or presence-absence), underlying mathematical framework, response curve capabilities, and computational dependencies.
Period covered: 2024/2026. Coverage: Global.
| Algorithm | Function Call | Data Requirement | Mathematical Framework | Response Shape | External Dependencies |
|---|---|---|---|---|---|
| BIOCLIM | bioclim() | Presence-only | Rectilinear percentile bounding envelope | Stepwise percentile range | None (base R / raster / terra) |
| DOMAIN | domain() | Presence-only | Gower point-to-point environmental distance metric | Continuous distance similarity decay | None (base R / raster / terra) |
| Mahalanobis Distance | mahal() | Presence-only | Multivariate variance-covariance distance | Elliptical distance contour | None (base R / raster / terra) |
| MaxEnt | maxent() | Presence-background | Maximum entropy relative entropy minimization | Complex non-linear (linear, quadratic, product, hinge) | Java >= 8, rJava, maxent.jar |
| Boosted Regression Trees | gbm.step() | Presence-absence or weighted pseudo-absence | Gradient boosted decision trees with cross-validation | High-order non-linear with interactions | gbm >= 2.1.1 |
| Geographic Distance | geoDist() | Presence-only | Spatial Euclidean or spherical distance decay | Geographic distance null decay | None (base R / raster / terra) |
| Convex Hulls | convHull() | Presence-only | Minimum bounding polygon null model | Binary in/out polygon boundary | deldir |
Sources
- CRAN Package dismo Reference Manual (accessed 2026-11-14)
- Species Distribution Modeling with R (rspatial.org) (accessed 2026-11-14)
- A statistical explanation of MaxEnt for ecologists (Elith et al. 2011) (accessed 2026-11-14)
- A working guide to boosted regression trees (Elith et al. 2008) (accessed 2026-11-14)
Compiled by CASRAI from the sources above. Free to reuse under CC BY 4.0 with attribution.







