[R] Creating a pixel image
Rolf Turner
rolf at erdos.math.unb.ca
Mon Aug 21 19:21:54 CEST 2006
Michael Lawton wrote:
> I am trying to create a pixel image from the marks of a marked
> spatial point pattern for use with the Kinhom function in the
> spatstat library and am having some difficulty. Is there a way to
^^^^^^^
***package*** !!!
(NOT ``library'')
> create such an object using x-y coordinates and values at those
> coordinates?
It is not clear to me what you actually want to do, but there
are tools in spatstat which may accomplish your purpose. In
particular, the function as.im() (see the on-line help) will
take a function of the form ``function(x,y,...)'' (and a
window W) and convert that function into an image defined on W.
So if you have or can create a function which will calculate
the ``values at those coordinates'' then there is no problem.
Otherwise you will need to explain more clearly what it is
that you want.
If your are thinking of an ``image'' where the value is, say,
10, at points of the pattern whose marks are of type 1, and
say -10, at points of the pattern whose marks are of type 2,
and say 0 at ``background'' points, then this is readily
accomplished using nearest.raster.point(). But I don't think
you gain anything by representing the point pattern as an image
in this way, and this is not the sort of thing that one would
feed to Kinhom().
Quite often an input to Kinhom() would be calculated by
``smoothing'' the field of ``delta functions'' corresponding
to a collection of points. The function density.ppp() is
a good way to accomplish this. Choosing the ``bandwidth''
parameter sigma for the smooth is however a bit of a mystery,
apparently even to the cognoscenti.
cheers,
Rolf Turner
rolf at math.unb.ca
P. S. A library, as someone --- Martin Maechler??? --- has repeatedly
tried to explain to the list, is a *collection of packages*. One
loads a package *from a library* by using the library() function.
R. T.
More information about the R-help
mailing list