Fast Spatial Species Accumulation Curves

High-performance spatial species accumulation curves using fixed-focus spatially constrained rarefaction, nearest-centroid expansion, and nearest-neighbor walks with a C++ backend for speed. Supports Hill numbers (q=0,1,2), beta diversity partitioning (turnover/nestedness) at site and pooled resolution, coverage-based rarefaction and extrapolation of alpha and beta diversity, phylogenetic diversity (PD; Faith's PD, EvoHeritage, mean pairwise distance, mean nearest taxon distance), functional diversity accumulation including aggregated functional diversity and intraspecific trait variation, phylogenetic and functional redundancy, interaction network accumulation, diversity-area relationships (DAR), endemism-area curves, sampling-effort correction and fragmentation analysis, species-area relationship (SAR) models based on extreme value theory (EVT), and area-based richness extrapolation via the total-species curve. Total richness is also estimated from frequency counts, including the accumulation rate curve estimator and an estimator for sites sampled without replacement, and shift-and-rotate null models test the position of a sampling design. Multiple starting points (seeds) provide uncertainty quantification. Methods are described in Chao et al. (2014) , Baselga (2010) , Chao and Jost (2012) , Faith (1992) , Ma (2018) , Borda-de-Agua et al. (2025) , Hanski et al. (2013) , Jost (2007) , Ugland et al. (2003) , Chao et al. (2023) , Chiu (2023) , Chiu et al. (2023) , Rosindell et al. (2024) , Wojcik et al. (2024) , Ridder et al. (2024) , Jones et al. (2025) , and Shestopaloff (2025) .


spacc

species accumulating in the neighbourhood

CRANstatus CRANdownloads Monthlydownloads R-CMD-check Codecov testcoverage License:MIT

spacc builds species accumulation curves that add sampling sites in the order of their distance from a starting point, such as plots added one by one outward from a point in a survey region, and shows how the curve changes with that point.

The classical curve of specaccum() in vegan adds sites in random order, without using their spatial arrangement. spacc samples a focal point in continuous space, ranks every site by its distance from that point and counts the new species along the ranking. It repeats this from many focal points in C++ with RcppParallel, so the curve carries a confidence ribbon showing how richness depends on where the expansion begins. spacc also computes the random-order curve, so you can compare the two and judge how much the spatial arrangement of your sites matters.

spacc supports:

  • Seven expansion orders. Fixed-focus nearest neighbours, nearest-centroid expansion, a nearest-neighbour walk, distance-weighted and direction-weighted growth, the classical random order and the data order, chosen through method.
  • Diversity beyond richness. Hill numbers, beta diversity with turnover and nestedness, coverage-based rarefaction, and phylogenetic and functional diversity accumulate along the same spatial order; spaccHill() is the entry point.
  • Geographic coordinates. distance = "haversine" works on longitude and latitude with no projection step, and an sf polygon through focal_domain restricts the focal points to a known study boundary.
  • Large site sets. Above 500 sites the nearest-neighbour walk switches from a distance matrix to a ball tree that drops visited sites as the walk proceeds, and the centroid walk recomputes only the distances that the centroid’s movement could have made the smallest, for Euclidean and haversine distances alike (How spatial accumulation works).
  • Fitting and comparing curves. extrapolate() fits asymptotic richness models, including Michaelis-Menten, Lomolino, Weibull, logistic and extreme value models, and compare() tests two curves by permutation, bootstrap or area under the curve.

Existing curves from vegan::specaccum() enter through as_spacc(), so they share the plotting and comparison methods. Each method follows a published definition, listed with its reference in the DESCRIPTION and in How spatial accumulation works, and a methods section can cite those papers for the estimators and spacc for the spatial ordering.

Installation

Install the released version from CRAN. Windows and macOS get a binary that needs no build tools:

install.packages("spacc")

The development version compiles C++ code. Install the build tools for your operating system first:

Operating system Build tools
Windows Rtools matching your R version
macOS Run xcode-select --install in Terminal
Debian / Ubuntu Install r-base-dev

Check that R can find the compiler:

pkgbuild::has_build_tools(debug = TRUE)

Then install spacc from GitHub:

# install.packages("pak")
pak::pak("gcol33/spacc")

The build needs GNU make and a C++17 compiler, which the build tools above provide. RcppParallel brings its own threading library, so no system libraries are needed.

Usage

  1. Build a spatial accumulation curve with spacc() from a site-by-species matrix and the site coordinates.
  2. Build the random-order curve with method = "random" and test the difference with compare().
  3. Fit an asymptote with extrapolate(), or follow other diversity measures with spaccHill() and spaccBeta().

The input is a matrix or data frame with one row per site and one column per species, with presence-absence or abundance values, and the site coordinates as a data frame with columns x and y or an sf object of points. Coordinates are planar by default; distance = "haversine" reads the two columns as longitude and latitude in degrees.

In the example below, each of 40 species occurs around its own position along the x axis, so neighbouring sites share species:

library(spacc)

set.seed(1)
coords <- data.frame(x = runif(200), y = runif(200))
centres <- runif(40)
prob <- outer(coords$x, centres, function(x, m) exp(-(x - m)^2 / 0.02))
species <- matrix(rbinom(length(prob), 1, prob), nrow = 200)

sac <- spacc(species, coords)
plot(sac)
Species accumulation curve rising from about 10 species at one site to all 40 species at around 150 sites, with a green band showing the 95% interval of the curves from 50 focal points

The line is the mean over 50 focal points, and the ribbon spans the 2.5% and 97.5% quantiles of the curves from single focal points.

Adding the sites in random order reaches the species in fewer sites, because each new site comes from anywhere in the region instead of the already sampled neighbourhood:

sac_random <- spacc(species, coords, method = "random")
compare(sac, sac_random)
#> Comparison: sac vs sac_random 
#> ---------------------------------------- 
#> Method: permutation (n=999)
#> AUC difference: -1028.1 (p = 0.001**)
#> Saturation: sac at 90 sites, sac_random at 10 sites
#> 
#> sac_random saturates faster.

Diversity beyond richness

Each diversity function carries the spatial ordering through to a different measure. Per-site values come with map = TRUE, and as_sf() turns them into an sf object for GIS:

hill <- spaccHill(species, coords, q = c(0, 1, 2), map = TRUE)
plot(hill, type = "map", q = 0)

beta <- spaccBeta(species, coords, index = "sorensen")
plot(beta, partition = TRUE)

Accumulating Hill numbers and partitioning diversity covers Hill numbers and the alpha, beta and gamma partition, and Accumulating phylogenetic and functional diversity covers the phylogenetic and functional measures.

Grouped and spatiotemporal accumulation

groups splits the species into groups, such as native and alien species or families, and accumulates each under the same spatial site order. time adds a temporal axis to the distance; the two weights below set how much space and time each count:

sac_grouped <- spacc(species, coords, groups = status, seed = 42)
plot(sac_grouped, facet = TRUE)

sac_st <- spacc(species, coords, method = "nn_walk",
                time = site_years, w_space = 1, w_time = 0.5)

Comparing curves between groups and regions covers grouped curves and their comparison.

Documentation

Start with Getting started with spacc: one path from a site-by-species matrix to spatial and random-order curves, their comparison and extrapolation.

The article index groups the guides by task, and the first article of each group is the one to read first:

Getting help

Questions and bug reports go to the GitHub issues. A bug report is easiest to act on with a small reproducible example, for instance made with reprex.

Contributing

Pull requests are welcome; see the contributing guide.

Support

“Software is like sex: it’s better when it’s free.” — Linus Torvalds

I’m a PhD student who builds R packages in my free time because I believe good tools should be free and open. I started these projects for my own work and figured others might find them useful too.

If this package saved you some time, buying me a coffee is a nice way to say thanks. It helps with my coffee addiction.

Buy Me ACoffee

License

spacc is licensed under MIT.

Citation

Colling G (2026). _spacc: Fast Spatial Species Accumulation Curves_.
doi:10.32614/CRAN.package.spacc
<https://doi.org/10.32614/CRAN.package.spacc>. R package version 1.0.0,
<https://gillescolling.com/spacc/>.

BibTeX:

@Manual{colling2026spacc,
  title = {spacc: Fast Spatial Species Accumulation Curves},
  author = {Gilles Colling},
  year = {2026},
  note = {R package version 1.0.0},
  url = {https://gillescolling.com/spacc/},
  doi = {10.32614/CRAN.package.spacc},
}

Download the citation as BibTeX or RIS.

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("spacc")

1.0.0 by Gilles Colling, a day ago


https://gillescolling.com/spacc/, https://github.com/gcol33/spacc


Report a bug at https://github.com/gcol33/spacc/issues


Browse source code at https://github.com/cran/spacc


Authors: Gilles Colling [aut, cre, cph] (ORCID:


Documentation:   PDF Manual  


MIT + file LICENSE license


Imports Rcpp, RcppParallel, stats, parallel

Suggests testthat, knitr, rmarkdown, svglite, ggplot2, cli, sf, areaOfEffect, ape, iNEXT, iNEXT.3D, iNEXT.beta3D, betapart, cluster, vegan

Linking to Rcpp, RcppParallel

System requirements: GNU make


See at CRAN