Skip to content
Prev 6671 / 29559 Next

help using irregular polygons R with spatstat package

Raya A. Pruner <rpruner at ufl.edu>  writes:
This means that 'W' was not a recognised argument of 'as.ppp.SpatialPoints'. 

When you tried to convert the object 'nests.points' (of class "SpatialPoints") 
to the class "ppp" using the generic command 'as.ppp', the method 'as.ppp.SpatialPoints'
from the library 'maptools' was invoked. This function (which you can inspect by typing
its name) has only one argument, X. There is currently no facility to specify the window
by a second argument W.

The easiest way to get what you want is to use the 'ppp' command in spatstat.

nests.ppp <- ppp(nests.points[,1], nests.points[,2], window=boundary.owin)

Alternatively you could use the following modified version of 'as.ppp.SpatialPoints' 
which does behave as you wanted.

as.ppp.SpatialPoints <- function (X, W=NULL)
{
    require(spatstat)
    bb <- bbox(X)
    colnames(bb) <- NULL
    if(is.null(W)) W = owin(bb[1, ], bb[2, ])
    cc = coordinates(X)
    return(ppp(cc[, 1], cc[, 2], window = W, marks = NULL, check = FALSE))
}


regards
Adrian Baddeley