nearestTarget: Finds the nearest targets to a set of points within a...

View source: R/nearestTarget.R

nearestTargetR Documentation

Finds the nearest targets to a set of points within a specified radius.

Description

Calculates the distances between a set of points and target locations. It identifies the nearest target for each point and checks if the distance is within a specified radius. If a target is found within the radius, its index and distance are returned; otherwise, -1 is returned for both.

Usage

nearestTarget(data, targets, r)

Arguments

data

An object of class 'trajectory' containing a collection of points with coordinates.

targets

A matrix or data frame containing the coordinates of the target locations with rows representing targets.

r

A numeric value specifying the radius within which to consider targets.

Value

A data frame with two columns:

nt

Index of the nearest target for each point. If no target is found within the radius, this will be -1.

d

Distance to the nearest target. If no target is found within the radius, this will be -1.


BioTrajectory documentation built on Nov. 26, 2025, 5:07 p.m.