Package: blockCV 4.0-0

blockCV: Spatial and Environmental Blocking for Cross-Validation

Creates spatially or environmentally separated, or group-preserving, training and testing folds for k-fold, leave-group-out, and leave-one-out cross-validation. Provides spatial blocking, clustering, buffering, and nearest-neighbour distance-matching methods, together with tools to visualise folds, summarise fold sizes and class balance, and assess train–test separation and environmental novelty. Also estimates spatial autocorrelation ranges in point samples and continuous raster covariates to provide an initial distance scale for designing spatial folds. Methods are described in Valavi, R. et al. (2019) <doi:10.1111/2041-210X.13107>.

Authors:Roozbeh Valavi [aut, cre], Jane Elith [aut], José Lahoz-Monfort [aut], Ian Flint [aut], Gurutzeta Guillera-Arroita [aut]

blockCV_4.0-0.tar.gz
blockCV_4.0-0.zip(r-4.7)blockCV_4.0-0.zip(r-4.6)blockCV_4.0-0.zip(r-4.5)
blockCV_4.0-0.tgz(r-4.6-x86_64)blockCV_4.0-0.tgz(r-4.6-arm64)blockCV_4.0-0.tgz(r-4.5-x86_64)blockCV_4.0-0.tgz(r-4.5-arm64)
blockCV_4.0-0.tar.gz(r-4.7-arm64)blockCV_4.0-0.tar.gz(r-4.7-x86_64)blockCV_4.0-0.tar.gz(r-4.6-arm64)blockCV_4.0-0.tar.gz(r-4.6-x86_64)
blockCV_4.0-0.tgz(r-4.6-emscripten)
manual.pdf |manual.html
DESCRIPTION |NEWS
card.svg |card.png
blockCV/json (API)

# Install 'blockCV' in R:
install.packages('blockCV', repos = c('https://rvalavi.r-universe.dev', 'https://cloud.r-project.org'))

Bug tracker:https://github.com/rvalavi/blockcv/issues

Uses libs:
  • c++– GNU Standard C++ Library v3

On CRAN:

Conda:

cross-validationspatialspatial-cross-validationspatial-modellingspecies-distribution-modellingcpp

11.53 score 123 stars 4 packages 520 scripts 3.1k downloads 5 mentions 12 exports 45 dependencies

Last updated from:17d91e3c27. Checks:13 OK. Indexed: yes.

TargetResultTimeFilesSyslog
linux-devel-arm64OK206
linux-devel-x86_64OK219
source / vignettesOK284
linux-release-arm64OK203
linux-release-x86_64OK213
macos-release-arm64OK137
macos-release-x86_64OK289
macos-oldrel-arm64OK222
macos-oldrel-x86_64OK240
windows-develOK177
windows-releaseOK175
windows-oldrelOK224
wasm-releaseOK161

Exports:cv_block_sizecv_buffercv_clustercv_distancecv_groupcv_knndmcv_nndmcv_plotcv_similaritycv_spatialcv_spatial_autocorcv_summary

Dependencies:abindautomapclassclassIntclicowplotcpp11DBIe1071farverFNNggplot2gluegstatgtableintervalsisobandKernSmoothlabelinglatticelifecycleMASSplyrproxyR6RColorBrewerRcppreshaperlangs2S7scalessfsftimespspacetimestarsterraunitsvctrsviridisLitewithrwkxtszoo

blockCV introduction: how to create block cross-validation folds
Introduction | Installation | Package data | Block cross-validation strategies | Spatial blocks | Spatial and environmental clustering | Leave-group-out cross-validation | Buffering LOO (also known as Spatial LOO) | Nearest Neighbour Distance Matching (NNDM) LOO | k-fold Nearest Neighbour Distance Matching (kNNDM) | Visualising the folds | Next steps | References:

Last update: 2026-07-10
Started: 2023-01-29

Choosing and diagnosing spatial folds
Introduction | Prepare data and folds | Fold-quality summary | Environmental similarity diagnostics | Nearest-neighbour distance diagnostics | Choosing a candidate block size | References:

Last update: 2026-07-09
Started: 2023-01-29

Block cross-validation for species distribution modelling
Introduction | Reading and plotting data | Generating block CV folds | Evaluating SDMs with block cross-validation: examples | Using blockCV with Random Forest model | Using blockCV in biomod2 package | References:

Last update: 2026-07-09
Started: 2026-07-09

Using blockCV with caret
Introduction | Prepare the data | Create spatial folds | Fit a caret model | References

Last update: 2026-07-09
Started: 2026-07-09