Package index
-
spatialkitspatialkit-package - spatialkit: Spatial Tessellation, Modeling, and Cross-Validation Toolkit
-
ensure_projected() - Ensure an object has a projected CRS (with sensible defaults)
-
harmonize_crs() - Harmonize CRS between two spatial objects
-
coerce_to_points() - Coerce arbitrary geometries to representative points
-
clip_target_for() - Build a polygonal clip target from points and/or a boundary
-
prep_model_data() - Prepare and sanitize an sf dataset for spatial modeling
Measure the spatial structure
The distance over which observations stay correlated. It sizes both the cells and the cross-validation blocks.
-
estimate_sac_range() - Estimate the spatial autocorrelation range from data
-
sac_nugget() - The nugget of an estimated autocorrelation range
-
print(<sac_range>) - Print a spatial autocorrelation range
-
plot(<sac_range>) - Plot an estimated spatial autocorrelation range
-
determine_optimal_levels() - Determine an optimal number of spatial levels via an elbow heuristic
-
resolution_profile() - Score every candidate number of cells on several criteria at once
-
select_resolution() - Read a level, and the region over which it is not distinguishable, off a profile
-
summary(<resolution_profile>) - Every criterion's pick, side by side
-
print(<resolution_profile>) - Print a resolution profile
-
plot(<resolution_profile>) - Plot a resolution profile
-
build_tessellation() - Build a tessellation (Voronoi, Delaunay triangles, hex grid, or square grid)
-
get_voronoi_seeds() - Generate seed points for Voronoi tessellation
-
voronoi_seeds_kmeans() - K-means seed generation from point coordinates
-
voronoi_seeds_random() - Random seed generation within a polygonal boundary
-
create_voronoi_polygons() - Create Voronoi polygons from points with CRS handling and optional clipping
-
create_grid_polygons() - Create square or hexagonal grid polygons over a boundary
-
create_grid_polygons_cached() - Create and cache grid polygons over a boundary
-
ensure_stable_poly_id() - Create deterministic, stable polygon IDs based on spatial sort keys
-
plot_tessellation_map() - Plot a tessellation map with optional boundary, seeds, and features
Assign and aggregate
One row per cell, with a count and a standard error for every aggregate, the record of which rows were dropped or tied on the way, and whether a block-kriging estimate would have beaten the plain cell mean.
-
assign_features_to_polygons() - Assign features to polygons and attach a polygon ID
-
summarize_by_cell() - Summarize features by polygon/cell ID
-
kriging_adequacy() - Block-kriging adequacy diagnostics for a set of cells
-
`[`(<spatialkit_rows>) - Subset a layer that carries a row record
Fold
Spatial cross-validation folds, how large the blocks should be, and how far the held-out points ended up from the training data.
-
make_folds() - Create spatial cross-validation folds
-
plot_folds() - Map a cross-validation fold scheme
-
fold_separation() - How far the held-out points actually sit from the training data
-
cv_block_size_sweep() - Cross-validate at a ladder of block sizes
-
plot(<block_size_sweep>) - Plot cross-validation error against block size
-
new_spatial_fit() - Build a spatial_fit S3 object
-
fit_rf_model() - Fit a random forest via ranger
-
fit_gwr_model() - Fit a Geographically Weighted Regression (GWR) via GWmodel
-
fit_bayesian_spatial_model() - Fit a Bayesian spatial regression with a 2D Gaussian Process (via brms)
-
gp_lengthscale_bounds() - Heuristic length-scale bounds for a squared-exponential GP
Choose the predictors
Forward selection scored on spatial folds for any backend, and an AICc search over predictor sets for GWR.
-
select_features_forward() - Greedy forward feature selection with spatially blocked inner folds
-
plot(<feature_selection>) - Plot the path of a forward feature selection
-
gwr_model_selection() - Forward model selection for geographically weighted regression
-
print(<gwr_model_selection>) - Print a GWR model selection result
-
plot(<gwr_model_selection>) - Plot a GWR model selection
-
print(<spatial_fit>) - Print a fitted spatial model
-
summary(<spatial_fit>) - Summarise a fitted spatial model
-
plot(<spatial_fit>) - Plot a fitted spatial model
-
predict(<rf_fit>) - Predict from a random forest fit
-
predict(<gwr_fit>) - Predict from a GWR spatial model
-
predict(<bayesian_fit>) - Predict from a Bayesian spatial GP model
-
fitted(<rf_fit>) - Out-of-bag predictions from a random forest fit
-
fitted(<gwr_fit>) - In-sample fitted values from a GWR fit
-
fitted(<bayesian_fit>) - In-sample fitted values from a Bayesian spatial GP fit
-
residuals(<rf_fit>) - Out-of-bag residuals from a random forest fit
-
residuals(<gwr_fit>) - In-sample residuals from a GWR fit
-
residuals(<bayesian_fit>) - In-sample residuals from a Bayesian spatial GP fit
-
coef(<rf_fit>) - Coefficients are undefined for a random forest
-
coef(<gwr_fit>) - Extract GWR local coefficients
-
coef(<bayesian_fit>) - Extract Bayesian model fixed-effect summaries
-
print(<rf_fit>) - Print a random forest fit
Read a fit in sample
Metrics on the training data (out-of-bag for a forest), and the residual checks that say whether structure was left behind. In-sample numbers are not comparable across backends; compare_models_cv() is.
-
model_metrics() - Compute goodness-of-fit metrics for a spatial model
-
evaluate_insample() - Compute in-sample (or out-of-sample) metrics for fitted spatial models
-
compare_models() - Side-by-side comparison of fitted spatial models
-
residual_morans_i() - Compute Moran's I on the residuals of a fitted spatial model
-
print(<morans_i>) - Print a residual Moran's I result
-
cv_spatial() - Model-agnostic spatial cross-validation
-
cv_rf() - Cross-validate a random forest with spatial folds
-
cv_gwr() - K-fold cross-validation for GWR
-
cv_bayes() - K-fold cross-validation for the Bayesian spatial model
-
compare_models_cv() - Cross-validated comparison of spatial models
-
plot_cv_metrics() - Plot one cross-validation metric fold by fold
-
plot_calibration() - Plot the interval calibration of a Bayesian cross-validation
-
predict_surface() - Predict a fitted spatial model onto a regular grid
-
area_of_applicability() - Area of applicability of a spatial prediction model
-
print(<aoa>) - Print an area-of-applicability result
-
plot(<aoa>) - Plot the dissimilarity distribution behind an area of applicability
Package options and caches
The console log, and the two in-session caches. Both caches are keyed on the inputs, so they only need clearing when memory is the constraint.
-
spatialkit_quiet() - Quieten (or restore) spatialkit's console log
-
clear_grid_cache() - Clear the in-session grid cache
-
clear_fitted_cache() - Clear cached fitted values for a Bayesian spatial model