[R-sig-Geo] after running as.ppp(), all points lying outside the window

Barry Rowlingson b.rowlingson at lancaster.ac.uk
Wed Apr 5 11:46:44 CEST 2017


On Wed, Apr 5, 2017 at 8:27 AM, Musa, Kamarul Imran
<k.musa at lancaster.ac.uk> wrote:
> str_typ2 <- as.ppp(str_typ, W = Win)

as.ppp is using the first two columns of your data frame for
coordinates, the first one in yours is the mark!

So you have:

 > str_typ = data.frame(mark=sample(2,1135,TRUE), x=runif(1135,388992,
503274), y=runif(1135, 516003, 689283))
 > Win <- owin(c(388992,503274), c(516002,689283))
 > str_typ2 <- as.ppp(str_typ, W = Win)
Warning message:
1135 points were rejected as lying outside the specified window

But do the data frame with x,y,mark and it works:

 > str_typ = data.frame(x=runif(1135,388992, 503274), y=runif(1135,
516003, 689283), mark=sample(2,1135,TRUE))
 > str_typ2 <- as.ppp(str_typ, W = Win)

Probably better to use `ppp()` to construct a marked `ppp` object:

  str_typ2 <- ppp(x=str_typ$x, y=str_typ$y, marks=str_typ$mark, window=Win)

Note the window argument is `window=` here, in other places in
`spatstat` its `W` or `Win` or other things!

Barry



More information about the R-sig-Geo mailing list