[R] Finding the neighbors of the point

Roger Bivand Roger.Bivand at nhh.no
Fri Oct 21 22:11:38 CEST 2005


On Fri, 21 Oct 2005, Leaf Sun wrote:

> Dear all,
> 
> I got point data of trees. I was wondering if anybody has experience in searching the neighbors within a specified distance efficiently.
> 
> X    Y     Z
> 99 	34	 65
> 98 	35	 29
> 98 	34	 28
> 99 	33	 33
> 98 	32	 23
> 99 	33	 21
> 99 	33	 22
> 99 	32	 24
> 99 	30	 23
>     ...
> 

> What I want to do is :  searching for the neighbors with a distance R
> for each tree & the neighbor must have a bigger Z.
> 
> 
> The data set is huge so the R-codes is working slowly when I search it
> without subset it.
> 

And huge is how big? For very large problems, you'll need a kd-tree or 
r-tree approach to divide up the point locations before making the spatial 
query (I think the retention of neighbours with a larger z is the final 
step). There do not seem to be such functions in R or contributed packages 
at present. If you are willing to collaborate, I can pass on a draft 
package corrected by Christian Sangiorgio for approximate nearest 
neighbours (an interface to ANN by David Mount and collaborators), but it 
isn't working yet. So an investment in time and some knowledge of C++ will 
be useful.

> Any suggestion would be much appreciated!
> 
> Leaf
> 
> 

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no




More information about the R-help mailing list