{"id":19253631,"url":"https://github.com/tidymodels/spatialsample","last_synced_at":"2025-05-08T21:17:48.003Z","repository":{"id":37049263,"uuid":"331109525","full_name":"tidymodels/spatialsample","owner":"tidymodels","description":"Create and summarize spatial resampling objects 🗺","archived":false,"fork":false,"pushed_at":"2024-10-02T23:47:40.000Z","size":96435,"stargazers_count":74,"open_issues_count":5,"forks_count":5,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-05-08T21:17:32.908Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://spatialsample.tidymodels.org","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tidymodels.png","metadata":{"files":{"readme":"README.Rmd","changelog":"NEWS.md","contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-01-19T21:06:51.000Z","updated_at":"2025-04-28T01:31:04.000Z","dependencies_parsed_at":"2024-09-06T09:42:55.798Z","dependency_job_id":"f8715da8-77ba-4c1a-b039-519b212181f0","html_url":"https://github.com/tidymodels/spatialsample","commit_stats":{"total_commits":112,"total_committers":4,"mean_commits":28.0,"dds":0.3482142857142857,"last_synced_commit":"de9b7a42a62c7eba0bc2c10b5193d648d7ea8ae6"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tidymodels%2Fspatialsample","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tidymodels%2Fspatialsample/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tidymodels%2Fspatialsample/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tidymodels%2Fspatialsample/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tidymodels","download_url":"https://codeload.github.com/tidymodels/spatialsample/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253149622,"owners_count":21861740,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-09T18:32:21.846Z","updated_at":"2025-05-08T21:17:47.945Z","avatar_url":"https://github.com/tidymodels.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\noutput: github_document\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r, include = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\",\n  out.width = \"100%\"\n)\nlibrary(ggplot2)\ntheme_set(theme_minimal())\n```\n\n# spatialsample \u003ca href=\"https://spatialsample.tidymodels.org\"\u003e\u003cimg src=\"man/figures/logo.png\" align=\"right\" height=\"138\" alt=\"A hand-drawn map with orange roads, blue rivers, green trees, and brown mountains on a beige background\" /\u003e\u003c/a\u003e\n\n\u003c!-- badges: start --\u003e\n[![R-CMD-check](https://github.com/tidymodels/spatialsample/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/tidymodels/spatialsample/actions/workflows/R-CMD-check.yaml)\n[![CRAN status](https://www.r-pkg.org/badges/version/spatialsample)](https://CRAN.R-project.org/package=spatialsample)\n[![Codecov test coverage](https://codecov.io/gh/tidymodels/spatialsample/branch/main/graph/badge.svg)](https://app.codecov.io/gh/tidymodels/spatialsample?branch=main)\n[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html)\n\u003c!-- badges: end --\u003e\n\n## Introduction\n\nThe goal of spatialsample is to provide functions and classes for spatial resampling to use with [rsample](https://rsample.tidymodels.org/), including:\n\n- [spatial clustering cross-validation](https://doi.org/10.1109/IGARSS.2012.6352393)\n- [spatial block cross-validation](https://doi.org/10.1111/ecog.02881)\n- [spatially buffered cross-validation](https://doi.org/10.1111/geb.12161)\n- [leave-location-out cross-validation](https://doi.org/10.1016/j.envsoft.2017.12.001)\n\nLike [rsample](https://rsample.tidymodels.org/), 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.\n\n## Installation\n\nYou can install the released version of spatialsample from [CRAN](https://CRAN.R-project.org) with:\n\n``` r\ninstall.packages(\"spatialsample\")\n```\n\nAnd the development version from [GitHub](https://github.com/) with:\n\n``` r\n# install.packages(\"pak\")\npak::pak(\"tidymodels/spatialsample\")\n```\n## Example\n\nThe most straightforward spatial resampling strategy is `spatial_clustering_cv()`, which uses k-means clustering to identify cross-validation folds:\n\n```{r}\nlibrary(spatialsample)\n\nset.seed(1234)\nfolds \u003c- spatial_clustering_cv(boston_canopy, v = 5)\n\nfolds\n```\n\nIn 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.\n\nIn addition to resampling algorithms, spatialsample provides methods to visualize resamples using [ggplot2](https://ggplot2.tidyverse.org/) through the `autoplot()` function:\n\n```{r 2022-06-12_boston_static, fig.width=7, fig.height=5}\nautoplot(folds)\n```\n\nWe can use the same function to visualize each fold separately:\n\n```{r 2022-06-12_boston-anim, animation.hook=\"gifski\", fig.width=7, fig.height=5}\nlibrary(purrr)\n\nwalk(folds$splits, function(x) print(autoplot(x)))\n```\n\nSo far, we've only scratched the surface of the functionality spatialsample provides. For more information, check out the [Getting Started](https://spatialsample.tidymodels.org/articles/spatialsample.html) documentation!\n\n## Contributing\n\nThis project is released with a [Contributor Code of Conduct](https://contributor-covenant.org/version/2/1/CODE_OF_CONDUCT.html). By contributing to this project, you agree to abide by its terms.\n\n- For questions and discussions about tidymodels packages, modeling, and machine learning, please [post on RStudio Community](https://forum.posit.co/new-topic?category_id=15\u0026tags=tidymodels,question).\n\n- If you think you have encountered a bug, please [submit an issue](https://github.com/tidymodels/rules/issues).\n\n- Either way, learn how to create and share a [reprex](https://reprex.tidyverse.org/articles/articles/learn-reprex.html) (a minimal, reproducible example), to clearly communicate about your code.\n\n- Check out further details on [contributing guidelines for tidymodels packages](https://www.tidymodels.org/contribute/) and [how to get help](https://www.tidymodels.org/help/).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftidymodels%2Fspatialsample","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftidymodels%2Fspatialsample","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftidymodels%2Fspatialsample/lists"}