[R-sig-Geo] nearest neighbor 3d point pattern

Carsten Neumann carstennh at aol.com
Fri Jun 28 13:29:24 CEST 2013


Thank you very much Rolf,

an enlightening example for me! To my example: the 3D array should be
interpreted as a regular point pattern just as a reproducible example
(number of points = 11*11*11 / 1. coordinate = 0,0,0.1 / 2. coordinate =
0,0,0.2 etc.). The second point has the same structure than the first
(number of points = 1*1*1 coordinates = 0.8,0.3,0.5). Maybe this type of
example depiction is some kind of confusing!? So my question was meant,
which coordinates of points 2 are closest to coordinates of point 1. I
know, for a regular Grid pattern like my array example no big question.
But in case of real irregular geographic point pattern your example is a
beginning (I need to translate this for 23 billion points).

Best

Carsten

On 06/28/2013 01:34 AM, Rolf Turner wrote:
> On 27/06/13 23:40, Carsten Neumann wrote:
>> Dear list members,
>>
>> after searching R mailing lists, I wonder if there is a R function that
>> can find the nearest neighbor/or just euclidean distance of points in
>> one 3D coordinate system to points in another 3D coordinate system. The
>> function nncross {spatstat} can only deal with 2D point pattern. Any
>> idea or experiences with such procedures?
>>
>> ######################Test Data############################
>> point1<-array(c(seq(0,1,0.1),seq(0,1,0.1),seq(0,1,0.1)),dim=c(11,11,11))
>> point2<-array(c(0.8,0.3,0.5),dim=c(1,1,1))
>> #########################################################
>> question: where is point2 in point1?
>
> You are correct in that nncross() has not (yet) been extended to three
> dimensional point patterns.  However a workaround can be found by
> using crossdist.pp3().
>
> E.g.:
>
>     set.seed(42)
>     X     <- ppx(data.frame(x=rnorm(20),y=rnorm(20),z=rnorm(20)))
>     Y      <- ppx(data.frame(x=0,y=0,z=0))
>     M     <- crossdist(Y,X)
>     min(M)
>     which.min(M)
>
> This will tell you that the nearest point in X to c(0,0,0) is point
> number 15
> and the distance from c(0,0,0) to this point is 0.5299162.
>
> I'm afraid I could not comprehend your example.  The object point1 is
> a 3-dimensional array (11 x 11 x 11).  How is this to be interpreted as
> a 3-dimensional *point pattern*?  And point2 is a single number --- 0.8,
> and not actually a point in 3-space.
>
> Furthermore what does the question "where is point2 in point1?" mean?
> I cannot parse this question.
>
> Perhaps (quite possibly) I am just being stupid.  If so, please
> enlighten me.
>
>     cheers,
>
>         Rolf Turner
>
>

-- 

Carsten Neumann
Telegrafenberg, A 17 01.13
14473 Potsdam
-------------------------------------------------------
Helmholtz Centre Potsdam
GFZ German Research Centre for Geosciences
Department 1 - Section 1.4 - Remote Sensing
-------------------------------------------------------
Tel.: +49 (0) 331 288 1766
e-mail: carstenn at gfz-potsdam.de



More information about the R-sig-Geo mailing list