Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

maxnndist

Compute Minimum or Maximum Nearest-Neighbour Distance


Description

A faster way to compute the minimum or maximum nearest-neighbour distance in a point pattern.

Usage

minnndist(X, positive=FALSE, by=NULL)
maxnndist(X, positive=FALSE, by=NULL)

Arguments

X

A point pattern (object of class "ppp").

positive

Logical. If FALSE (the default), compute the usual nearest-neighbour distance. If TRUE, ignore coincident points, so that the nearest neighbour distance for each point is greater than zero.

by

Optional. A factor, which separates X into groups. The algorithm will compute the distance to the nearest point in each group.

Details

These functions find the minimum and maximum values of nearest-neighbour distances in the point pattern X. minnndist(X) and maxnndist(X) are equivalent to, but faster than, min(nndist(X)) and max(nndist(X)) respectively.

The value is NA if npoints(X) < 2.

Value

A single numeric value (possibly NA).

If by is given, the result is a numeric matrix giving the minimum or maximum nearest neighbour distance between each subset of X.

Author(s)

Adrian Baddeley Adrian.Baddeley@curtin.edu.au, Rolf Turner r.turner@auckland.ac.nz and Ege Rubak rubak@math.aau.dk.

See Also

Examples

min(nndist(swedishpines))
  minnndist(swedishpines)

  max(nndist(swedishpines))
  maxnndist(swedishpines)

  minnndist(lansing, positive=TRUE)

  if(interactive()) {
     X <- runifrect(1e6)
     system.time(min(nndist(X)))
     system.time(minnndist(X))
  }

  minnndist(amacrine, by=marks(amacrine))
  maxnndist(amacrine, by=marks(amacrine))

spatstat.geom

Geometrical Functionality of the 'spatstat' Family

v2.1-0
GPL (>= 2)
Authors
Adrian Baddeley [aut, cre], Rolf Turner [aut], Ege Rubak [aut], Tilman Davies [ctb], Ute Hahn [ctb], Abdollah Jalilian [ctb], Sebastian Meyer [ctb], Suman Rakshit [ctb], Dominic Schuhmacher [ctb], Rasmus Waagepetersen [ctb]
Initial release
2021-04-15

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.