Skip to content

cran/BoundaryStats

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BoundaryStats

BoundaryStats was designed to test for the presence of geographic boundaries in ecological variables and overlap between such boundaries. Users can calculate boundary and boundary overlap statistics with raster data. BoundaryStats can create null distributions for the statistics based on various neutral landscape models that are parameterized on the empirical data. The primary functions are statistical tests for the presence of spatial boundaries of a variable and significant overlap between the spatial boundaries of two variables.

DOI

Installation

You can install BoundaryStats with either:

install.packages('BoundaryStats')
remotes::install_github("aluo734/BoundaryStats")

Statistical Tests

Function

Category

Description

n_boundaries

Boundary

The number of subgraphs, or sets of contiguous boundary elements, in the data.

longest_boundary

Boundary

The length of the longest subgraph.

n_overlap_boundaries

Boundary Overlap

The number of directly overlapping boundary elements, or raster cells labeled as part of a boundary, of two traits.

average_min_x_to_y

Boundary Overlap

The average minimum distance between each boundary element in raster x and the nearest boundary element in raster y. Uses Euclidean distance. The boundaries of trait x depend on the boundaries of trait y.

average_min_distance

Boundary Overlap

The average minimum distance between boundary elements in two raster layers. Uses Euclidean distance. Boundaries for each trait affect one another reciprocally (x affects y and y affects x).

Example

library(BoundaryStats)
library(tidyverse)

data(ecoregions)
ecoregions <- terra::rast(ecoregions_matrix, crs = ecoregions_crs)
terra::ext(ecoregions) <- ecoregions_ext

data(L.flavomaculatus)
L.flavomaculatus <- terra::rast(L.flavomaculatus_matrix, crs = L.flavomaculatus_crs)
terra::ext(L.flavomaculatus) <- L.flavomaculatus_ext

terra::crs(ecoregions) <- terra::crs(L.flavomaculatus)
ecoregions <- terra::resample(ecoregions, L.flavomaculatus) |>
  terra::crop(L.flavomaculatus) |>
  terra::mask(L.flavomaculatus)
L.flavomaculatus <- terra::crop(L.flavomaculatus, ecoregions) |>
  terra::mask(ecoregions)

L.flavomaculatus_boundary <- define_boundary(L.flavomaculatus, cat = TRUE)
ecoregions_boundary <- define_boundary(ecoregions, cat = T)
plot_boundary(L.flavomaculatus, ecoregions)

Tcrist_ovlp_null <- overlap_null_distrib(L.flavomaculatus, ecoregions, rand_both = FALSE, x_cat = T, n_iterations = 100, x_model = 'random_cluster')

n_overlap_boundaries(L.flavomaculatus, ecoregions, Tcrist_ovlp_null)
average_min_x_to_y(L.flavomaculatus, ecoregions, Tcrist_ovlp_null)
average_min_distance(L.flavomaculatus, ecoregions, Tcrist_ovlp_null)

Data source: Cox, Karen; Schepers, Robbert; Van Breusegem, An; Speybroeck, Jeroen (2023), The common ground in landscape effects on gene flow in two newt species in an agroecosystem, Dryad, Dataset, https://doi.org/10.5061/dryad.bk3j9kdhz.

About

❗ This is a read-only mirror of the CRAN R package repository. BoundaryStats — Boundary Overlap Statistics

Resources

Stars

0 stars

Watchers

2 watching

Forks

Packages

 
 
 

Contributors

Languages