Skip to contents

This function takes two dataframes containing point coordinates (pixel column and pixel row) in the first two columns and identifies the nearest "spot" in the second dataframe for each point in the first dataframe, considering a maximum distance and a maximum number of neighbors. The coordinate ID needs to be in the rownames of the input dataframes.

Usage

MapPointsToReference(
  ref_coords,
  map_coords,
  distance_max = NULL,
  n_neighbors = 100,
  verbose = TRUE
)

Arguments

ref_coords

A dataframe containing the reference point coordinates with the first two columns corresponding to x- and y- pixel coordinates and coordinate IDs as rownames.

map_coords

A dataframe containing the coordinates of point to map to the reference, with the first two columns corresponding to x- and y- pixel coordinates and coordinate IDs as rownames.

distance_max

The maximum distance threshold for considering a spot as a neighbor (defaults to half the minimum distance between reference points).

n_neighbors

The maximum number of neighbors to consider for each reference point (defaults to 100).

verbose

Logical indicating whether to print informative messages during execution. Defaults to TRUE.

Value

A dataframe with "map_coord_IDs" indicating the nearest map spot ID for each point in the reference dataframe.