# Nearest neighbour

I have a point with spatial and temporal coordinates

x=(lonx,latx,timex)


and I would like to find the nearest neighbour (according to some metric) amongst these other points

y1 = c(lony1,laty1,timey1)
y2 = c(lony2,laty2,timey2)
...
yn = c(lonyn,latyn,timeyn)


Is there any nearest-neighbour algorithm that I can use?