adjacent: Determine adjacent points

Description Usage Arguments Details Value Examples

View source: R/adjacent.R

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

1
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

1
2
3
4
5
6
7
# 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 Jan. 25, 2020, 1:07 a.m.