grtsdb

Spatially balanced sampling based on the General Randomized Tessellation Stratified (GRTS) using R and SQLite

https://github.com/inbo/grtsdb

Science Score: 44.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (17.9%) to scientific vocabulary

Keywords

grts r r-package r-stats sampling sampling-methods sqlite
Last synced: 4 months ago · JSON representation ·

Repository

Spatially balanced sampling based on the General Randomized Tessellation Stratified (GRTS) using R and SQLite

Basic Info
Statistics
  • Stars: 1
  • Watchers: 7
  • Forks: 0
  • Open Issues: 1
  • Releases: 2
Topics
grts r r-package r-stats sampling sampling-methods sqlite
Created over 6 years ago · Last pushed almost 4 years ago
Metadata Files
Readme Changelog Contributing License Code of conduct Citation Zenodo

README.Rmd

---
output: github_document
---



```{r, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)
```

# grtsdb


[![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)
[![Lifecycle: maturing](https://img.shields.io/badge/lifecycle-maturing-blue.svg)](https://lifecycle.r-lib.org/articles/stages.html)
![GitHub](https://img.shields.io/github/license/inbo/grtsdb)
[![R build status](https://github.com/inbo/grtsdb/workflows/R-CMD-check/badge.svg)](https://github.com/inbo/grtsdb/actions)
[![Codecov test coverage](https://codecov.io/gh/inbo/grtsdb/branch/master/graph/badge.svg)](https://app.codecov.io/gh/inbo/grtsdb?branch=master)
![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/inbo/grtsdb.svg)
![GitHub repo size](https://img.shields.io/github/repo-size/inbo/grtsdb.svg)


The goal of `grtsdb` is to create a spatially balanced sample based on the 'Generalised Random Tesselation Stratified' strategy.
We store the base schema in an SQLite database to make the sampling reproducible.
Sampling the same database with the same parameters yields a stable sample.

## Installation

To install the latest stable version use

``` r
# activate the INBO r-universe
options(
  repos = c(
    INBO = 'https://inbo.r-universe.dev', CRAN = 'https://cloud.r-project.org'
  )
)
install.packages("grtsdb")
```

You can install the development version from [GitHub](https://github.com/) with:

``` r
# install.packages("remotes")
remotes::install_github("inbo/grtsdb")
```

## Example

This is a basic example.

Connect to a database.

```{r}
tmp_copy <- tempfile(pattern = "grts", fileext = ".sqlite")
if (system.file("grts.sqlite", package = "grtsdb") != "") {
  file.copy(system.file("grts.sqlite", package = "grtsdb"), tmp_copy)
}
library(grtsdb)
db <- connect_db(tmp_copy)
```

To extract a sample, you'll need to specify the bounding box in projected coordinates and the size of the grid cells.

```{r example}
bbox <- rbind(
  c(0, 32),
  c(0, 32)
)
extract_sample(grtsdb = db, samplesize = 10, bbox = bbox, cellsize = 1)
```

Repeating the sample yields the same results.

```{r}
extract_sample(grtsdb = db, samplesize = 10, bbox = bbox, cellsize = 1)
```

```{r echo = FALSE}
drop_legacy_sites(grtsdb = db, level = 5)
```

You can add legacy sites to the sampling scheme.

```{r}
legacy <- rbind(
  c(4, 4),
  c(17, 6)
)
add_legacy_sites(legacy, bbox = bbox, cellsize = 1, grtsdb = db)
extract_legacy_sample(grtsdb = db, samplesize = 10, bbox = bbox, cellsize = 1)
```

You can compact the database for storage.

```{r}
compact_db(db)
```

Disconnect the database when done.

```{r}
dbDisconnect(db)
```

```{r eval = system.file("grts.sqlite", package = "grtsdb") == "", echo = FALSE}
dir.create("inst", showWarnings = FALSE)
file.copy(tmp_copy, file.path("inst", "grts.sqlite"))
```

Owner

  • Name: Research Institute for Nature and Forest (INBO)
  • Login: inbo
  • Kind: organization
  • Location: Belgium

Open source, data and science initiatives of the Research Institute for Nature and Forest (INBO)

Citation (CITATION.cff)

cff-version: 1.2.0
message: If you use this software, please cite it as below.
authors:
- family-names: Onkelinx
  given-names: Thierry
  orcid: https://orcid.org/0000-0001-8804-4216
- family-names: De Vos
  given-names: Bruno
  orcid: https://orcid.org/0000-0001-9523-3453
contact:
- email: thierry.onkelinx@inbo.be
  family-names: Onkelinx
  given-names: Thierry
- email: info@inbo.be
  name: Research Institute for Nature and Forest
title: 'grtsdb: Create a Sampling Frame Using GRTS'
version: '0.2'
abstract: Create an SQLite database containing the sampling framework for different
  levels of resolution. Take a sample from this framework.
license: GPL-3.0
type: software
repository-code: https://github.com/inbo/grtsdb
identifiers:
- type: url
  value: https://inbo.github.io/grtsdb/

GitHub Events

Total
Last Year

Committers

Last synced: 5 months ago

All Time
  • Total Commits: 50
  • Total Committers: 1
  • Avg Commits per committer: 50.0
  • Development Distribution Score (DDS): 0.0
Past Year
  • Commits: 0
  • Committers: 0
  • Avg Commits per committer: 0.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
Thierry Onkelinx t****x@i****e 50
Committer Domains (Top 20 + Academic)
inbo.be: 1

Issues and Pull Requests

Last synced: 5 months ago

All Time
  • Total issues: 1
  • Total pull requests: 1
  • Average time to close issues: N/A
  • Average time to close pull requests: 12 months
  • Total issue authors: 1
  • Total pull request authors: 1
  • Average comments per issue: 3.0
  • Average comments per pull request: 3.0
  • Merged pull requests: 1
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 0
  • Pull request authors: 0
  • Average comments per issue: 0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • hansvancalster (1)
Pull Request Authors
  • ThierryO (1)
Top Labels
Issue Labels
Pull Request Labels

Dependencies

DESCRIPTION cran
  • DBI * imports
  • RSQLite * imports
  • assertthat * imports
  • knitr * suggests
  • rmarkdown * suggests
  • testthat * suggests
  • tidyverse * suggests