0

I am having a few problems with creating a point pattern in the R package Spatstat.

> HI06mfav <- read.table("MarHI06mfav.txt", header = TRUE)
>  attach(HI06mfav)
The following object(s) are masked _by_ '.GlobalEnv':

x, y
The following object(s) are masked from 'HI06mfav (position 3)':

x, y
> HI06mfav.P <- ppp(x, y, c(-1, 11), c(-1, 11))
Warning message:
In ppp(x, y, c(-1, 11), c(-1, 11)) :
10 points were rejected as lying outside the specified window

> HI06mfav
      x        y
1  4.100800 6.526913
2  3.710310 6.189953
3  3.030026 6.696919
4  2.747816 6.417674
5  2.955485 6.125787
6  3.299942 5.922913
7  2.932207 5.549772
8  2.681645 5.641663
9  1.858555 5.686039
10 2.069101 5.427891
11 2.387927 5.227459
12 2.530470 5.383951
13 2.783648 5.019703
14 2.219491 4.767310
15 6.591515 8.160451
16 6.600408 8.567767
17 3.098551 3.561141
18 2.634305 3.571341

I have used this same code before and everything worked fine, so I am confused at why it is not working now. I know that I might need to use an alternative to attach(), but I don't understand the error after I try to create the ppp.

It even does the same thing with example code taken right from the Spatstat guide:

> w <- owin(c(-1,1), c(-1,1))
> w <- as.mask(w)
> X <- raster.x(w)
> Y <- raster.y(w)
> M <- (X^2 + Y^2 <= 1)
> pp <- ppp(x, y, c(-1,1), c(-1,1), mask=M)
Warning message:
In ppp(x, y, c(-1, 1), c(-1, 1), mask = M) :
10 points were rejected as lying outside the specified window
> pp
planar point pattern: 0 points 
window: binary image mask
100 x 100 pixel array (ny, nx)
enclosing rectangle: [-1, 1] x [-1, 1] units  

I am going back through the spatstat guide to try to figure this out, but any help would be very much appreciated.

markalex
  • 8,623
  • 2
  • 7
  • 32
  • 1
    Your spatstat code works fine, so it has to be accessing the columns of the attached data frame. `library(spatstat);x <- c(4.1008,3.71031,3.030026,2.747816,2.955485,3.299942,2.932207,2.681645,1.858555,2.069101,2.387927,2.53047,2.783648,2.219491,6.591515,6.600408,3.098551,2.634305);y <- c(6.526913,6.189953,6.696919,6.417674,6.125787,5.922913,5.549772,5.641663,5.686039,5.427891,5.227459,5.383951,5.019703,4.76731,8.160451,8.567767,3.561141,3.571341);ppp(x, y, c(-1, 11), c(-1, 11))`. – Andy W Aug 02 '13 at 20:56
  • There's no problem, you just have a few points that fall outside the observation window is all. – Simon O'Hanlon Aug 02 '13 at 22:31
  • Well @SimonO101, if you look at the results there are 0 points that fall within the window! The error message about the columns being masked in `HI06mfav.P` is pretty straightforward, just print `x` and `y` to see what they actually are, or use `HI06mfav.P$x` etc. when forming the point pattern. – Andy W Aug 02 '13 at 22:50
  • Just do `ppp(HI06mfav$x, HI06mfav$y, c(-1, 11), c(-1, 11))` – Simon O'Hanlon Aug 02 '13 at 23:04
  • or `with(HI06mfav, ppp(x,y, c(-1,11), c(-1,11)))` – Adrian Baddeley Oct 28 '16 at 01:17

0 Answers0