[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 09:27:20 CEST 2017


Dear all,

I was trying to plot 1135 points using spatstat package. The data points were in the CSV file, and I would like to convert them to a ppp object so I can run relrisk().  Unfortunately, after running as.ppp(), I received a warning message and when plotted, all the points were lying outside the rectangle window. I have been looking for answers elsewhere but could not find the right one for me, so I hope if anyone can help, then I would be grateful. 

The file is in the dropbox folder (https://www.dropbox.com/s/90yxvd5cwnvbty8/stroke_typhoid_RSO2.csv?dl=0) for those interested to download. But the codes and results that I have run are listed below:

1) When I run str(), it gives these:

> str(str_typ)
'data.frame':	1135 obs. of  3 variables:
 $ mark: int  1 2 2 2 2 2 2 1 2 2 ...
 $ x   : int  388992 422451 429127 430811 432153 432153 432306 432862 432887 433456 ...
 $ y   : int  516003 575800 627691 629927 624186 624186 617470 638829 615294 607246 ...

2) The summary returns these:

> summary(str_typ)
      mark             x                          y         
 Min.   :1.000   Min.   :388992      Min.   :516003  
 1st Qu.:1.000   1st Qu.:467048   1st Qu.:660183  
 Median :1.000   Median :474740   Median :669192  
 Mean   :1.303   Mean   :473189   Mean   :664687  
 3rd Qu.:2.000   3rd Qu.:481698   3rd Qu.:676389  
 Max.   :2.000   Max.   :503274   Max.   :689283  

3) To create the Window, I used this:

Win <- owin(c(388992,503274), c(516002,689283))

4) Then, I run as.ppp()
 
> str_typ2 <- as.ppp(str_typ, W = Win)
Warning message:
1135 points were rejected as lying outside the specified window 

5) When I run plot()
> plot(str_typ2)
Warning message:
In plot.ppp(str_typ2) : 1135 illegal points also plotted

6) What I could see is that all points were lying outside the rectangle box.

Best regards,
Kamarul
USM, Malaysia 



         


More information about the R-sig-Geo mailing list