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

Musa, Kamarul Imran k.musa at lancaster.ac.uk
Wed Apr 5 14:56:49 CEST 2017


Dear Barry,

It works! I must make sure that the coordinates are correctly specified and positioned. And that I need to use 'window' and not 'W' in the arguments. Really appreciate your help.

Regards,
Kamarul

________________________________________
From: b.rowlingson at gmail.com [b.rowlingson at gmail.com] on behalf of Barry Rowlingson [b.rowlingson at lancaster.ac.uk]
Sent: Wednesday, April 05, 2017 5:46 PM
To: Musa, Kamarul Imran
Cc: r-sig-geo at r-project.org
Subject: Re: [R-sig-Geo] after running as.ppp(), all points lying outside the window

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