[R-sig-Geo] Point pattern add covariates

Rolf Turner r.turner at auckland.ac.nz
Mon Jul 23 23:29:36 CEST 2012


On 24/07/12 01:26, Jose Funes wrote:
> Dear list,
> I have point pattern data and would like to attach/add covariates as raster
> (image or grid) to it. For example as the case of the bei data with
> bei.extra with covariates.

I'm afraid I don't understand what it is that you need to do.
What do you mean by "attach/add"?  In the example of the
"bei" data that you refer to, the images (covariates) "elev"
and "grad" are components of the list "bei.extra" which is
a separate object from the point pattern "bei".  The object
"bei.extra" is not "attached" to the object "bei" in any way.

Barry Rowlingson suggested that you might want to find the
values of a covariate associated with each point of a point
pattern.   The easiest way to do this is to use the (undocumented)
function "lookup.im()".

E.g.:

     em <- with(bei.extra,lookup.im(elev,bei$x,bei$y))
     gm <- with(bei.extra,lookup.im(grad,bei$x,bei$y))

Then you could "attach" these values to the point pattern as
*marks*:

     marks(bei) <- data.frame(elev=em,grad=gm)

Is this (anything like) what you want to do?

     cheers,

         Rolf Turner

P. S.  Adrian:  Do you think we should make "lookup.im()" into a 
*documented*
function?  I have found myself recommending its use to inquirers on more 
than
one occasion.

         R.



More information about the R-sig-Geo mailing list