X
this function computes, for each desired location y
,
the mark attached to the nearest neighbour of y
in X
.
The desired locations y
can be either a pixel grid
or the point pattern X
itself.
nnmark(X, ..., k = 1, at=c("pixels", "points"))
"ppp"
).
as.mask
to determine the
pixel resolution.
k
th nearest data point will be used.
at="pixels"
) or
only at the points of X
(at="points"
).
X
has a single column of marks:
at="pixels"
(the default), the result is
a pixel image (object of class "im"
).
The value at each pixel is the mark attached
to the nearest point of X
.
at="points"
, the result is a vector or factor
of length equal to the number of points in X
.
Entries are the mark values of the
nearest neighbours of each point of X
.
X
has a data frame of marks:
at="pixels"
(the default), the result is a named list of
pixel images (object of class "im"
). There is one
image for each column of marks. This list also belongs to
the class "solist"
, for which there is a plot method.
at="points"
, the result is a data frame
with one row for each point of X
,
Entries are the mark values of the
nearest neighbours of each point of X
.
X
this function computes, for each desired location y
,
the mark attached to the point of X
that is nearest
to y
. The desired locations y
can be either a pixel grid
or the point pattern X
itself. The argument X
must be a marked point pattern (object
of class "ppp"
, see ppp.object
).
The marks are allowed to be a vector or a data frame.
at="points"
, then for each point in X
,
the algorithm finds the nearest other point in X
,
and extracts the mark attached to it.
The result is a vector or data frame containing the marks
of the neighbours of each point.
at="pixels"
(the default), then for each pixel
in a rectangular grid, the algorithm finds the nearest point in X
,
and extracts the mark attached to it.
The result is an image or a list of images containing the marks
of the neighbours of each pixel.
The pixel resolution is controlled by the arguments ...
passed to as.mask
.
If the argument k
is given, then the k
-th nearest
neighbour will be used.
Smooth.ppp
,
marktable
,
nnwhich
plot(nnmark(ants))
v <- nnmark(ants, at="points")
v[1:10]
plot(nnmark(finpines))
vf <- nnmark(finpines, at="points")
vf[1:5,]
Run the code above in your browser using DataLab