I am using the nn2() function within the RANN package to find nearest neighbors, within a specific radius, of points identified by latitudes and longitudes.
What unit is that radius measured in?
I have looked in the RANN and ANN documentation but have not found the answer. An example using a subset of my coordinates in copied below.
------------------------ Example ------------------------------
library("RANN")
> #Data contains longitude and latitudes of points
> long<-c(-0.12541369, -0.06148541, -0.10533759, -0.06067756, -0.13908847)
> lat<-c(51.51735, 51.49540, 51.53120, 51.54869, 51.51602)
>
> data<-cbind(long,lat)
>
> #Setting radius
> #Here is my question -- what is the unit of radius?
> radius<-.05
>
> #Identifying neighbors
> res <- nn2(data, k=nrow(data), searchtype="radius", radius = radius)
>
> #Counts of neighbors
> count <- cbind(data,rowSums(res$nn.idx > 0) - 1)
>
> #View output
> colnames(count)[3]<-"nn_count"
> head(count)
long lat nn_count
[1,] -0.12541369 51.51735 2
[2,] -0.06148541 51.49540 0
[3,] -0.10533759 51.53120 3
[4,] -0.06067756 51.54869 1
[5,] -0.13908847 51.51602 2