Package: spatialkit 2.0.0.9000

spatialkit: Spatial Tessellation, Modeling, and Cross-Validation Toolkit

Constructs analysis regions from the distribution of the data itself, as an alternative to aggregating onto administrative boundaries that were drawn for unrelated purposes. Seeds and builds Voronoi, Delaunay, hexagonal and square tessellations with reproducible identifiers, selects a cell count from the spatial structure of the observations, assigns features to cells, and aggregates to cell level with optional design-effect corrections so that standard errors account for within-cell autocorrelation. Also manages coordinate reference systems. Fits geographically weighted regression (via 'GWmodel'; Lu et al. (2014) <doi:10.1080/10095020.2014.917453>), Bayesian spatial Gaussian process regression (via 'brms', using the Hilbert space approximation of Riutort-Mayol et al. (2023) <doi:10.1007/s11222-022-10167-2>) and random forests (via 'ranger', with the permutation importance of Strobl et al. (2007) <doi:10.1186/1471-2105-8-25>), each behind one S3 class with consistent predict, fitted, residuals and plot methods. Provides spatial cross-validation with random, block, buffered, leave-location-out and nearest-neighbour distance-matched folds (Mila et al. (2022) <doi:10.1111/2041-210X.13851>), forward variable selection, model comparison, prediction onto a regular surface, and the area of applicability of Meyer and Pebesma (2021) <doi:10.1111/2041-210X.13650> to flag where a fitted model extrapolates beyond its training data.

Authors:Justin Chase [aut, cre, cph]

spatialkit_2.0.0.9000.tar.gz
spatialkit_2.0.0.9000.zip(r-4.7-any)spatialkit_2.0.0.9000.zip(r-4.6-any)spatialkit_2.0.0.9000.zip(r-4.5-any)
spatialkit_2.0.0.9000.tgz(r-4.6-any)spatialkit_2.0.0.9000.tgz(r-4.5-any)
spatialkit_2.0.0.9000.tar.gz(r-4.7-any)spatialkit_2.0.0.9000.tar.gz(r-4.6-any)
spatialkit_2.0.0.9000.tgz(r-4.6-emscripten)
manual.pdf |manual.html✨
DESCRIPTION |NEWS
card.svg |card.png
spatialkit/json (API)

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

Bug tracker:https://github.com/elkronos/gis_modeling_toolkit/issues

Pkgdown/docs site:https://elkronos.github.io

On CRAN:

Conda:

cross-validationgeographically-weighted-regressiongeospatialgissfspatial-analysisspatial-cross-validationspatial-statisticstesselationvoronoi

6.60 score 7 stars 21 scripts 371 downloads 49 exports 28 dependencies

Last updated from:227c8e1ace. Checks:9 OK. Indexed: yes.

TargetResultTimeFilesSyslog
linux-develOK585
source / vignettesOK348
linux-releaseOK412
macos-releaseOK425
macos-oldrelOK431
windows-develOK471
windows-releaseOK486
windows-oldrelOK328
wasm-releaseOK281

Exports:area_of_applicabilityassign_features_to_polygonsbuild_tessellationclear_fitted_cacheclear_grid_cacheclip_target_forcoerce_to_pointscompare_modelscompare_models_cvcreate_grid_polygonscreate_grid_polygons_cachedcreate_voronoi_polygonscv_bayescv_block_size_sweepcv_gwrcv_rfcv_spatialdetermine_optimal_levelsensure_projectedensure_stable_poly_idestimate_sac_rangeevaluate_insamplefit_bayesian_spatial_modelfit_gwr_modelfit_rf_modelfold_separationget_voronoi_seedsgp_lengthscale_boundsgwr_model_selectionharmonize_crskriging_adequacymake_foldsmodel_metricsnew_spatial_fitplot_calibrationplot_cv_metricsplot_foldsplot_tessellation_mappredict_surfaceprep_model_dataresidual_morans_iresolution_profilesac_nuggetselect_features_forwardselect_resolutionspatialkit_quietsummarize_by_cellvoronoi_seeds_kmeansvoronoi_seeds_random

Dependencies:classclassIntcliDBIdigestdplyre1071genericsglueKernSmoothlifecycleloggermagrittrpillarpkgconfigproxyR6Rcpprlangs2sftibbletidyselectunitsutf8vctrswithrwk

Choosing a resolution
The question | A fixture with known structure | The short answer | The profile | The four criteria | Choosing, and the flat region | What the ladder can support | Choosing on one half, estimating on the other | Next

Last update: 2026-09-27
Started: 2026-09-17

Diagnostics
Four questions a score does not answer | A fixture and a model that is wrong in a known way | 1. Structure left in the residuals | 2. Standard errors on aggregated values | 3. Is the cell mean the best estimate of the cell? | 4. Where the score applies | 5. Two ways to leak | Next

Last update: 2026-09-27
Started: 2026-09-17

Getting started
What this package is for | Installing | Getting your data in | A spatial file | A table with coordinate columns | What the numbers are in | The pipeline, end to end | Regions and aggregates | Cells or points? | A model, scored honestly | A surface, and where to trust it | Where to go next | Words that recur

Last update: 2026-09-27
Started: 2026-09-17

Spatial cross-validation
The problem with a random fold | A learner you can read | The size of the effect | The five fold schemes | How wide should a block be? | Sizing it by measurement | Reading the result | Every row and every fold is accounted for | Calibration, for a model with intervals | Next

Last update: 2026-09-27
Started: 2026-09-17

spatialkit: Tessellations, Spatial Cross-Validation and Models
Overview | 1. Packages and boundary | 2. Synthetic observations | 3. Four tessellations | 3a. Voronoi from ~40 k-means seeds | 3b and 3c. Hex and square grids (~50 cells) | 3d. Delaunay triangles | 4. Cell-level aggregation with summarize_by_cell() | Choropleths | 5. Spatial cross-validation | 5a. How far does correlation reach? | 5b. Two fold schemes on the same data | 5c. The number the fold scheme changes | 6. Fitting a model | Residual diagnostics | GWR, if GWmodel is installed | Comparing backends on identical folds | 7. From a fit to a map, and where the map applies | Summary | Where to go next

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

What to save, and what to report
The regions as a file someone else can use | Grouping a layer you already have | Is this location inside? | IDs that survive a reprojection | Writing it out | The numbers the run already recorded | A worked report | What each line is for | What to save | Next | References

Last update: 2026-09-27
Started: 2026-09-19

Readme and manuals

Help Manual

Help pageTopics
Subset a layer that carries a row record[.spatialkit_rows
Area of applicability of a spatial prediction modelarea_of_applicability
Assign features to polygons and attach a polygon IDassign_features_to_polygons
Build a tessellation (Voronoi, Delaunay triangles, hex grid, or square grid)build_tessellation
Clear cached fitted values for a Bayesian spatial modelclear_fitted_cache
Clear the in-session grid cacheclear_grid_cache
Build a polygonal clip target from points and/or a boundaryclip_target_for
Extract Bayesian model fixed-effect summariescoef.bayesian_fit
Extract GWR local coefficientscoef.gwr_fit
Coefficients are undefined for a random forestcoef.rf_fit
Coerce arbitrary geometries to representative pointscoerce_to_points
Side-by-side comparison of fitted spatial modelscompare_models
Cross-validated comparison of spatial modelscompare_models_cv
Create square or hexagonal grid polygons over a boundarycreate_grid_polygons
Create and cache grid polygons over a boundarycreate_grid_polygons_cached
Create Voronoi polygons from points with CRS handling and optional clippingcreate_voronoi_polygons
K-fold cross-validation for the Bayesian spatial modelcv_bayes
Cross-validate at a ladder of block sizescv_block_size_sweep
K-fold cross-validation for GWRcv_gwr
Cross-validate a random forest with spatial foldscv_rf
Model-agnostic spatial cross-validationcv_spatial
Determine an optimal number of spatial levels via an elbow heuristicdetermine_optimal_levels
Ensure an object has a projected CRS (with sensible defaults)ensure_projected
Create deterministic, stable polygon IDs based on spatial sort keysensure_stable_poly_id
Estimate the spatial autocorrelation range from dataestimate_sac_range
Compute in-sample (or out-of-sample) metrics for fitted spatial modelsevaluate_insample
Fit a Bayesian spatial regression with a 2D Gaussian Process (via brms)fit_bayesian_spatial_model
Fit a Geographically Weighted Regression (GWR) via GWmodelfit_gwr_model
Fit a random forest via rangerfit_rf_model
In-sample fitted values from a Bayesian spatial GP fitfitted.bayesian_fit
In-sample fitted values from a GWR fitfitted.gwr_fit
Out-of-bag predictions from a random forest fitfitted.rf_fit
How far the held-out points actually sit from the training datafold_separation
Generate seed points for Voronoi tessellationget_voronoi_seeds
Heuristic length-scale bounds for a squared-exponential GPgp_lengthscale_bounds
Forward model selection for geographically weighted regressiongwr_model_selection
Harmonize CRS between two spatial objectsharmonize_crs
Block-kriging adequacy diagnostics for a set of cellskriging_adequacy
Create spatial cross-validation foldsmake_folds
Compute goodness-of-fit metrics for a spatial modelmodel_metrics model_metrics.spatial_fit
Build a spatial_fit S3 objectnew_spatial_fit
Plot the interval calibration of a Bayesian cross-validationplot_calibration
Plot one cross-validation metric fold by foldplot_cv_metrics
Map a cross-validation fold schemeplot_folds
Plot a tessellation map with optional boundary, seeds, and featuresplot_tessellation_map
Plot the dissimilarity distribution behind an area of applicabilityplot.aoa
Plot cross-validation error against block sizeplot.block_size_sweep
Plot the path of a forward feature selectionplot.feature_selection
Plot a GWR model selectionplot.gwr_model_selection
Plot a resolution profileplot.resolution_profile
Plot an estimated spatial autocorrelation rangeplot.sac_range
Plot a fitted spatial modelplot.spatial_fit
Predict a fitted spatial model onto a regular gridpredict_surface
Predict from a Bayesian spatial GP modelpredict.bayesian_fit
Predict from a GWR spatial modelpredict.gwr_fit
Predict from a random forest fitpredict.rf_fit
Prepare and sanitize an sf dataset for spatial modelingprep_model_data
Print an area-of-applicability resultprint.aoa
Print a GWR model selection resultprint.gwr_model_selection
Print a residual Moran's I resultprint.morans_i
Print a resolution profileprint.resolution_profile
Print a random forest fitprint.rf_fit
Print a spatial autocorrelation rangeprint.sac_range
Print a fitted spatial modelprint.spatial_fit
Compute Moran's I on the residuals of a fitted spatial modelresidual_morans_i
In-sample residuals from a Bayesian spatial GP fitresiduals.bayesian_fit
In-sample residuals from a GWR fitresiduals.gwr_fit
Out-of-bag residuals from a random forest fitresiduals.rf_fit
Score every candidate number of cells on several criteria at onceresolution_profile
The nugget of an estimated autocorrelation rangesac_nugget
Greedy forward feature selection with spatially blocked inner foldsselect_features_forward
Read a level, and the region over which it is not distinguishable, off a profileselect_resolution
Quieten (or restore) spatialkit's console logspatialkit_quiet
Summarize features by polygon/cell IDsummarize_by_cell
Every criterion's pick, side by sidesummary.resolution_profile
Summarise a fitted spatial modelsummary.spatial_fit
K-means seed generation from point coordinatesvoronoi_seeds_kmeans
Random seed generation within a polygonal boundaryvoronoi_seeds_random