coincident: Determine coincident coordinates

View source: R/dist_funcs.R

coincidentR Documentation

Determine coincident coordinates

Description

coincident takes the coordinate matrices coords1 and coords2 and returns the indices of the coincident coordinates of the two matrices.

Usage

coincident(coords1, coords2)

Arguments

coords1

An n1 \times 2 numeric matrix of coordinates.

coords2

An n2 \times 2 numeric matrix of coordinates.

Details

This function calls a compiled C++ program created using the Rcpp package. This (may) result in a significant speedup over pure R code since the search algorithm involves loops. We assume that there are no duplicate coordinates in coords1 and coords2, respectively. In other words, each row of coords1 is unique and each row of coords2 is unique. There is at most 1 row of coords1 that will match with a row in coords2.

Value

Returns a matrix with the indices of the coincident locations. Specifically, an r \times 2 matrix will be returned, with r being the number of coordinates in coords1 coinciding with coordinates in coords2. If row i of the matrix is c(2, 5), then the ith set of coincident locations is between the 2nd row of coords1 and the 5th row of coords2. If there are no coincident locations, then a matrix of size 0 \times 2 is returned.

Author(s)

Joshua French

Examples

#Generate two sets of coordinates
loc1 <- as.matrix(expand.grid(seq(0, 1, len = 25), seq(0, 1, len = 25)))
loc2 <- as.matrix(expand.grid(seq(0, 1, len = 101), seq(0, 1, len = 101)))
coincident(loc1, loc2)

jpfrench81/SpatialTools documentation built on July 29, 2023, 8:01 a.m.