[R-sig-Geo] How extract multiple points from a buffer created from the same points?
GD
grothered at gmail.com
Mon Dec 2 06:22:38 CET 2013
Try this
library(sp)
# Hypothetical point coordinates -- 20 points in total, in a 'unit box'
mycoords=cbind(runif(20),runif(20))
# Chosen distance threshold for 'neighbours'
mythresh=0.2
# Distance matrix
myDists=spDists(mycoords)
# Compute neighbours -- store result in a list
# NOTE: All points have themselves as a neighbour
myNeighbours=list()
for(i in 1:nrow(mycoords)){
myNeighbours[[i]]=which(myDists[i,]<mythresh)
}
# To get indices of neighbours from e.g. mycoords[5,]
myNeighbours[[5]]
--
View this message in context: http://r-sig-geo.2731867.n2.nabble.com/How-extract-multiple-points-from-a-buffer-created-from-the-same-points-tp7585239p7585252.html
Sent from the R-sig-geo mailing list archive at Nabble.com.
More information about the R-sig-Geo
mailing list