distmap.ppp | R Documentation |
Computes the distance from each pixel to the nearest point in the given point pattern.
## S3 method for class 'ppp'
distmap(X, ..., clip=FALSE, metric=NULL)
X |
A point pattern (object of class |
... |
Arguments passed to |
clip |
Logical value specifying whether the resulting pixel image
should be clipped to the window of |
metric |
Optional. A distance metric
(object of class |
The “distance map” of a point pattern X
is the function
f
whose value f(u)
is defined for any two-dimensional
location u
as the shortest distance from u
to X
.
This function computes the distance map of the point pattern X
and returns the distance map as a pixel image. The greyscale value
at a pixel u
equals the distance from u
to the nearest
point of the pattern X
.
If clip=FALSE
(the default), the resulting pixel values are defined at every pixel in
the rectangle Frame(X)
. If clip=TRUE
, the pixel values are defined
only inside Window(X)
, and are NA
outside this window.
Computation is faster when clip=FALSE
.
Additionally, the return value
has two attributes, "index"
and "bdry"
, which are
also pixel images. The grey values in "bdry"
give the
distance from each pixel to the boundary of the window containing X
.
The grey values in "index"
are integers identifying which
point of X
is closest.
This is a method for the generic function distmap
.
Note that this function gives the distance from the
centre of each pixel to the nearest data point.
To compute the exact distance from a given spatial location
to the nearest data point in X
, use distfun
or
nncross
.
A pixel image (object of class "im"
) whose greyscale values
are the values of the distance map.
The return value has attributes "index"
and "bdry"
which are also pixel images.
and \rolf
Generic function distmap
and other methods
distmap.psp
,
distmap.owin
.
Generic function distfun
.
Nearest neighbour distance nncross
U <- distmap(cells)
if(interactive()) {
plot(U)
plot(attr(U, "bdry"))
plot(attr(U, "index"))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.