I have 1 dataset of animals sighted walking a survey, and I would like to tag them to the respective sampling points along a transect.

Any idea what function/package in R can do that? Maybe something nearest neighbour related?

  • Take a look at the knearneigh and knn2nb functions in the spdep package. Honestly, if I had time I would flag this as a duplicate question because I know that I have answered this at least twice and others multiple times as well. Please perform a detailed search of the site. Dec 4, 2018 at 16:31

1 Answer 1


If I'm understanding your question correctly, you hope to get the distances between a set of points which represent animal sightings and another set of points which are sampling locations along a transect.

I'm not overly familiar with R, but it looks like the FNN package's get.knnx function might be of use to you. Take a look at this answer: Is there an R equivalent of NEAR in ESRI ArcGIS?

I'm not sure you have access to ArcGIS and an advanced license, but you could use the Near tool which provides distances from one set of points to another set of points.

  • 1
    If you believe that there is an existing answer to this question then you should flag it as a duplicate and not just provide your own answer linking to it. Dec 4, 2018 at 16:34
  • You're right. A comment would have been the better option in this instance as opposed to an answer. My thinking was to avoid discouraging a new user from posting and using GIS SE, especially a brand new user. That said, @JoanLee, Jeff makes a good point in his comment to your question.
    – jbrengel
    Dec 4, 2018 at 17:35

Not the answer you're looking for? Browse other questions tagged or ask your own question.