Skip to contents

Compares pairwise distances among sites with distances between the centers of the grid cells the sites fall in, and prints a report. Connectivity models that work from cell to cell treat each site as the center of its cell: the random walk functions (random_walk(), pairwise_random_walk()), and the least-cost functions when sites are snapped to cell centers (least_cost(), least_cost_paths(), and pairwise_least_cost(snap = TRUE)). For these, sites separated by only a few cells have distorted distances and directions, and sites in the same cell can't be distinguished at all. pairwise_least_cost() with its default snap = FALSE places sites at their actual locations, so this check does not apply to it.

Usage

check_cell_distance(x, ll, return = FALSE)

Arguments

x

A SpatRaster on the grid used for connectivity modeling, e.g. a wind_rose.

ll

A two-column matrix of site coordinates.

return

Logical: return the matrix of ratios? Default FALSE, which only prints the report.

Value

Prints the number of site pairs, the number (and percentage) in the same grid cell, and the distribution of discrepancies between cell and point distances, as percentages of point distance. If return = TRUE, also returns a matrix of the ratios of cell distances to point distances (NaN for a site with itself, and 0 for distinct sites in the same cell).

Details

Where many site pairs are affected, options are to use wind data on a finer grid, or to downscale() the wind rose (see its documentation for how downscaling changes random walk results).

Examples

rose <- windscape_example("wind_rose")
sites <- cbind(c(-110, -109.9, -100), c(35, 35.1, 40)) # the first two share a cell
check_cell_distance(rose, sites)
#> Total point pairs: 3
#> Point pairs in the same grid cell: 1 (33.3%)
#> Distribution of cell-point distance discrepancies:
#> 	0--1%: 0 (0%)
#> 	1--2.5%: 1 (33.3%)
#> 	2.5--5%: 1 (33.3%)
#> 	5--10%: 0 (0%)
#> 	10--25%: 0 (0%)
#> 	25--Inf%: 1 (33.3%)