On Wed, 20 Oct 2010, Rolf Turner wrote:


The spatstat package is designed for the analysis of spatial point
patterns.  In this context the existence of a window --- the
*observation* window --- is absolutely crucial.  You have to know where
points have been *looked for*, because there is information in where
the points aren't, as well as in where they are.  And you can't say
anything about where they aren't unless you know where they have been
looked for.

If you are putting spatstat to other uses where the nature of the process
generating the points is not of interest, and you want a default window
which has the nature of a bounding box, then this is easy to arrange.
E.g. you could write your own simple little utility, say

ppp_koh <- function(x,y,wrecked=TRUE,f,marks=NULL) {
require(spatstat)
ppp(x,y,window=ripras(x,y,shape=if(wrecked) "rectangle" else 
"convex",f=f),marks=marks)
}

Then you can do things like:
set.seed(42)
x <- runif(100,3,7)
y <- runif(100,-2,9)
X <- ppp_koh(x,y)

Or using the suite of coercion methods in in the maptools package:

library(maptools)
set.seed(42)
x <- runif(100,3,7)
y <- runif(100,-2,9)
xy <- SpatialPoints(cbind(x, y))
X <- as(xy, "ppp")

and so on. There are horses for courses, and the ppp, psp, im, and other representations, like polygons windows, are well tailored to their applications. So using coercion methods is a less invasive way of providing interoperability than trying to make a single set of representations fit all uses.

Roger


Note that by default the ripras() function called by ppp_koh() expands the
bounding box of the points slightly from extent of the data (to give a ``maximum
likelihood estimate'' of the bounding box).

If you don't want this expansion then specify f=1:

Y <- ppp_koh(x,y,f=1)

Note that this will cause at least two points of the pattern (and probably
four or more) to lie on the boundary of the window.

In genuine spatial point process applications one is advised to eschew
the use of the ripras() function.

        cheers,

                Rolf

On 19/10/2010, at 11:58 PM, Karl Ove Hufthammer wrote:

Rolf Turner wrote:

'ppp' objects used by 'spatstat' have an annoying structure

<SNIP>

Annoyance is in the mind of the beholder I think.  Personally I
find the structure of ppp objects absolutely *delightful*! :-)

Also, they are simple, intuitive, easy to work with, and easy to
understand, take apart, dissect, and manipulate.  Furthermore the
tools in spatstat make it easy to do unto ppp objects pretty well
anything one might want to do to a point pattern.  (I'm not being
immodest here; the tools are mainly down to Adrian.)

Just what do you find ``annoying'' about the structure of ppp objects?

Well, I guess only the fact that they’re not ‘sp’ objects, really. And
that’s very annoying … :)

And though the ‘window’ element of ‘ppp’ objects may be of use to some
people, I haven’t had any use for it. The annoying thing here is that the
constructor doesn’t generate the window automatically, based on the extent /
bounding box of the data, and don’t have an *option* for doing this, either.
Whenever I have used ‘spatstat’ (not too often), I have had to spend too
much time looking up how the window should be specified. Having [0,1] ×
[0,1] as the *default* window, and excluding any points outside this does
seems like a strange design decision.

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-sig-geo


--
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: roger.biv...@nhh.no
_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@stat.math.ethz.ch
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Reply via email to