Given a point pattern, this function constructs pixel images giving the distance from each pixel to its \(k\)-th nearest neighbour in the point pattern, and the index of the \(k\)-th nearest neighbour.
nnmap(X, k = 1, what = c("dist", "which"),
..., W = as.owin(X),
is.sorted.X = FALSE, sortby = c("range", "var", "x", "y"))A pixel image, or a list of pixel images.
By default (if what=c("dist", "which")), the result is
a list with two components dist and which
containing the distance map and the nearest neighbour map.
If what="dist" then the result is a real-valued pixel image
containing the distance map.
If what="which" then the result is an integer-valued pixel image
containing the nearest neighbour map.
If k is a vector of several integers, then the result is
similar except that each pixel image is replaced by a list of
pixel images, one for each entry of k.
Given a point pattern X, this function constructs two pixel images:
a distance map giving, for each pixel,
the distance to the nearest point of X;
a nearest neighbour map giving, for each pixel,
the identifier of the nearest point of X.
If the argument k is specified, then the k-th nearest
neighbours will be found.
If what="dist" then only the distance map is returned.
If what="which" then only the nearest neighbour map
is returned.
The argument k may be an integer or an integer vector.
If it is a single integer, then the k-th nearest neighbours
are computed. If it is a vector, then the k[i]-th nearest
neighbours are computed for each entry k[i]. For example, setting
k=1:3 will compute the nearest, second-nearest and
third-nearest neighbours.
distmap
plot(nnmap(cells, 2, what="which"))
Run the code above in your browser using DataLab