The goal of supercells is to bring the idea of superpixels into spatial analysis - grouping raster cells (not just image pixels) into meaningful, coherent regions. This package works on spatial data with one variable (e.g., continuous raster), many variables (e.g., RGB rasters), and spatial patterns (e.g., areas in categorical rasters). It is based on the SLIC algorithm (Achanta et al. (2012)), adapted to work with arbitrary dissimilarity measures and multidimensional data.
You can install the released version of supercells from CRAN with:
install.packages("supercells")You can install the development version with:
install.packages("supercells", repos = "https://nowosad.r-universe.dev")library(supercells)
library(terra)
library(sf)
vol = rast(system.file("raster/volcano.tif", package = "supercells"))
plot(vol)Here, step controls the approximate spacing between supercell centers,
and compactness allows to balance spatial proximity versus value
similarity.
vol_slic1 = sc_slic(vol, step = 8, compactness = 7)
plot(vol)
plot(st_geometry(vol_slic1), add = TRUE, lwd = 0.5, border = "red")Version 2 (in development) focuses on a clearer workflow, tools for diagnostics, and more guidance on choosing parameters and interpreting results. Start with these vignettes:
If you are already familiar with version 1.0.0, you can jump to the summary of changes:
Watch the presentations about this package and some related ideas:
- Spatial segmentation in R using the supercells package, 2021-09-02, OpenGeoHub Summer School - slides, video
- Generalizing the Simple Linear Iterative Clustering (SLIC) superpixels, 2021-09-28, GIScience 2021 - slides, video
Read the related article:
- Nowosad, J., Stepinski, T. (2022). Extended SLIC superpixels algorithm for applications to non-imagery geospatial rasters. International Journal of Applied Earth Observation and Geoinformation, https://doi.org/10.1016/j.jag.2022.102935
Contributions to this package are welcome – let us know if you need other distance measures or transformations, have any suggestions, or spotted a bug. The preferred method of contribution is through a GitHub pull request. Feel also free to contact us by creating an issue.


