Skip to content

Create and summarize spatial resampling objects 🗺

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md
Notifications You must be signed in to change notification settings

tidymodels/spatialsample

This branch is up to date with main.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ded1691 Â· Oct 2, 2024
Sep 4, 2024
Sep 4, 2024
Jun 14, 2022
Jun 14, 2022
Mar 14, 2023
Oct 2, 2024
Oct 2, 2024
Jul 14, 2022
Oct 2, 2024
Mar 14, 2023
Jan 4, 2023
May 26, 2022
Oct 2, 2024
Mar 13, 2023
Mar 13, 2023
Jun 13, 2023
Oct 2, 2024
Oct 2, 2024
Oct 2, 2024
May 15, 2023
Jan 20, 2021
Oct 2, 2024
May 26, 2022

Repository files navigation

spatialsample A hand-drawn map with orange roads, blue rivers, green trees, and brown mountains on a beige background

R-CMD-check CRAN status Codecov test coverage Lifecycle: experimental

Introduction

The goal of spatialsample is to provide functions and classes for spatial resampling to use with rsample, including:

Like rsample, spatialsample provides building blocks for creating and analyzing resamples of a spatial data set but does not include code for modeling or computing statistics. The resampled data sets created by spatialsample are efficient and do not have much memory overhead.

Installation

You can install the released version of spatialsample from CRAN with:

install.packages("spatialsample")

And the development version from GitHub with:

# install.packages("pak")
pak::pak("tidymodels/spatialsample")

Example

The most straightforward spatial resampling strategy is spatial_clustering_cv(), which uses k-means clustering to identify cross-validation folds:

library(spatialsample)

set.seed(1234)
folds <- spatial_clustering_cv(boston_canopy, v = 5)

folds
#> #  5-fold spatial cross-validation 
#> # A tibble: 5 × 2
#>   splits            id   
#>   <list>            <chr>
#> 1 <split [604/78]>  Fold1
#> 2 <split [595/87]>  Fold2
#> 3 <split [524/158]> Fold3
#> 4 <split [490/192]> Fold4
#> 5 <split [515/167]> Fold5

In this example, the boston_canopy data on tree cover in Boston, MA is resampled with v = 5; notice that the resulting partitions do not contain an equal number of observations.

In addition to resampling algorithms, spatialsample provides methods to visualize resamples using ggplot2 through the autoplot() function:

autoplot(folds)

We can use the same function to visualize each fold separately:

library(purrr)

walk(folds$splits, function(x) print(autoplot(x)))

So far, we’ve only scratched the surface of the functionality spatialsample provides. For more information, check out the Getting Started documentation!

Contributing

This project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

About

Create and summarize spatial resampling objects 🗺

Resources

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md

Code of conduct

Citation

Stars

Watchers

Forks

Packages

No packages published