<div>Dear Prof .Roger,</div>
<div> There is still a little problem with your method, the following are the programs:</div>
<p>a<-readShapePoly("d:/deleting/a/guichi2.shp") <br>W <-as(as(a, "SpatialPolygons"), "owin") # polygons window<br>plot(W)</p>
<p>cases<-coordinates(readShapePoints('d:/deleting/a/cases.shp')) #points<br>cases<-data.frame(cases)<br>names(cases)<-c("x","y")<br>cases[1:2,]</p>
<p>plot(W)<br>points(cases$x,cases$y) #no errors,83 points were inside the window</p>
<p>W<-as.owin(W)<br>points<-ppp(cases$x,cases$y,win=W) <font color="#ff0000"><strong>#????????????<br></strong></font><strong><font color="#ff0000">#error</font></strong>:83 points were rejected as lying outside the specified window in: ppp(cases$x, cases$y, win = W)
<br><strong><font color="#000099">In fact,</font></strong> 83 points were inside the specified window,what's wrong?</p>
<div>(This packages:<br>spatstat mgcv maptools foreign sp<br>"1.11-6" "1.3-24" "0.6-12" "0.8-20" "0.9-13")<br> BTW, i put the data in the attachment so that you can check it.
</div>
<div>Thanks.<br> </div>
<div><span class="gmail_quote">On 6/1/07, <b class="gmail_sendername">Roger Bivand</b> <<a href="mailto:Roger.Bivand@nhh.no">Roger.Bivand@nhh.no</a>> wrote:</span>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">On Fri, 1 Jun 2007, zhijie zhang wrote:<br><br>> Dear friends,<br>> I have a polygon, which is the shapefile format. I want to use it as the
<br>> window of points in ppp(x,y,window) of spatstat package, how should i do?<br>> The following programs can't work,:<br>> a<-readShapePoly("d:/deleting/a/a.shp") # read the boundary data<br>
> a2<-Polygon(coordinates(a), hole=as.logical(NA))<br>> ppp(x,y,a2)<br><br>Using the shapefile shipped with maptools:<br><br>library(maptools)<br>library(spatstat)<br>xx <- readShapePoly(system.file("shapes/sids.shp", package="maptools")[1])
<br>xx1 <- xx[1,] # and taking just the first county<br>plot(xx1)<br>W <- as(as(xx1, "SpatialPolygons"), "owin")<br>plot(W)<br>points(rpoispp(1000, win=W))<br><br>(This for:<br><br>other attached packages:
<br>spatstat mgcv maptools foreign sp<br>"1.11-5" "1.3-24" "0.6-12" "0.8-20" "0.9-13")<br><br>Hope this helps,<br><br>Roger<br><br><br>> THANKS.<br>><br>
<br>--<br>Roger Bivand<br>Economic Geography Section, Department of Economics, Norwegian School of<br>Economics and Business Administration, Helleveien 30, N-5045 Bergen,<br>Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
<br>e-mail: <a href="mailto:Roger.Bivand@nhh.no">Roger.Bivand@nhh.no</a><br><br></blockquote></div><br><br clear="all"><br>-- <br>With Kind Regards,<br><br>oooO:::::::::<br>(..):::::::::
<br>:\.(:::Oooo:: <br>::\_)::(..):: <br>:::::::)./::: <br>::::::(_/:::: <br>:::::::::::::<br>[***********************************************************************]
<br>Zhi Jie,Zhang ,PHD <br>Tel:86-21-54237149 <br>Dept. of Epidemiology,School of Public Health,Fudan University <br>Address:No. 138 Yi Xue Yuan Road,Shanghai,China <br>Postcode:200032 <br><a href="mailto:Email:epistat@gmail.com">
Email:epistat@gmail.com</a> <br>Website: <a href="http://www.statABC.com">www.statABC.com</a><br>[***********************************************************************]<br>oooO:::::::::<br>(..):::::::::
<br>:\.(:::Oooo:: <br>::\_)::(..):: <br>:::::::)./::: <br>::::::(_/:::: <br>:::::::::::::