[R-sig-Geo] How should i change the shaplefile of a polygon to be used as a window in ppp function of spatstat?
Roger Bivand
Roger.Bivand at nhh.no
Fri Jun 1 09:26:39 CEST 2007
On Fri, 1 Jun 2007, zhijie zhang wrote:
> Dear friends,
> I have a polygon, which is the shapefile format. I want to use it as the
> window of points in ppp(x,y,window) of spatstat package, how should i do?
> The following programs can't work,:
> a<-readShapePoly("d:/deleting/a/a.shp") # read the boundary data
> a2<-Polygon(coordinates(a), hole=as.logical(NA))
> ppp(x,y,a2)
Using the shapefile shipped with maptools:
library(maptools)
library(spatstat)
xx <- readShapePoly(system.file("shapes/sids.shp", package="maptools")[1])
xx1 <- xx[1,] # and taking just the first county
plot(xx1)
W <- as(as(xx1, "SpatialPolygons"), "owin")
plot(W)
points(rpoispp(1000, win=W))
(This for:
other attached packages:
spatstat mgcv maptools foreign sp
"1.11-5" "1.3-24" "0.6-12" "0.8-20" "0.9-13")
Hope this helps,
Roger
> THANKS.
>
--
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no
More information about the R-sig-Geo
mailing list