# nncross

From spatstat v1.10-2
by Adrian Baddeley

##### Nearest Neighbour in Another Point Pattern

Given two point patterns `X`

and `Y`

,
finds the nearest neighbour in `Y`

of each point of `X`

.

##### Usage

`nncross(X, Y)`

##### Arguments

- X, Y
- Two point patterns (objects of class
`"ppp"`

).

##### Details

Given two point patterns `X`

and `Y`

this
function finds, for each point of `X`

, the
the nearest point of `Y`

. The distance between these points
is also computed.

The return value is a data frame, with rows corresponding to
the points of `X`

. The first column gives the nearest neighbour
distances (i.e. the `i`

th entry is the distance
from the `i`

th point of `X`

to the nearest point of
`Y`

). The second column gives the indices of the nearest
neighbours (i.e. the `i`

th entry is the index of
the nearest point in `Y`

.)

Note that this function is not symmetric in `X`

and `Y`

.
To find the nearest neighbour in `X`

of each point in `Y`

,
just use `nncross(Y,X)`

.

##### Value

- A data frame with two columns:
dist Nearest neighbour distance which Nearest neighbour index in `Y`

##### Examples

```
X <- runifpoint(15)
Y <- runifpoint(20)
N <- nncross(X,Y)$which
# note that length(N) = 15
plot(superimpose(X=X,Y=Y), main="nncross", cols=c("red","blue"))
arrows(X$x, X$y, Y[N]$x, Y[N]$y, length=0.15)
```

*Documentation reproduced from package spatstat, version 1.10-2, License: GPL version 2 or newer*

### Community examples

Looks like there are no examples yet.