adjacent: Determine adjacent points

View source: R/adjacent.R

adjacentR Documentation

Determine adjacent points

Description

adjacent attempts to find the point(s) adjacent (closest) to each point. The data are implicitly assumed to be on a grid, otherwise this function isn't very useful. Distances between each point and other points in coords are computed and then rounded using the round function. Let k denote the minimum distance between a reference point and all other points. A point is adjacent to the reference point if (after rounding), it's distance from the reference point matches the minimum distance k.

Usage

adjacent(coords, longlat = FALSE, digits = 1)

Arguments

coords

A two-dimensional matrix-like object with non-NULL dimensions.

longlat

A logical value indicating whether Great Circle distances should be used (TRUE) or Euclidean distances (FALSE). The default is FALSE.

digits

The number of digits to use when applying round to the distances.

Details

digits is the number of digits used by round in the rounding process.

Value

A hero_adjacent object. This is simply a list with elements nbrs and coords. nbrs is a list specifying the adjacent points for each point. coords is simply the original coords supplied to the function and is retained for plotting purposes.

Examples

# basic coordinates
coords = expand.grid(1:4, 1:4)
# plot coordinates to see relationships
plot(coords, type = "n")
text(coords)
a = adjacent(coords, digits = 1)
plot(a)

hero documentation built on July 26, 2023, 5:11 p.m.