swin
creates an object of class "swin"
, which represents
the sampling window (or study region) in which a spatial point pattern was
observed. The ads
library supports simple (rectangular or circular) and complex
sampling windows.swin(window, triangles)
c(xmin,ymin,xmax,ymax)
for a rectangle ; c(x0,y0,r0)
for a circle."swin"
describing the sampling window. It may be of four different types
with different arguments:$type
c("simple","rectangle")
, c("simple","circle")
, c("complex","rectangle")
or c("complex","circle")
.$xmin,$ymin,$xmax,$ymax
$x0,$y0,$r0
$triangles
window=c(ximn,ymin,xmax,ymax)
a vector of length 4 giving the coordinates$(ximn,ymin)$and$(xmax,ymax)$of the origin and the opposite corner of a rectangle.window=c(x0,y0,r0)
a vector of length 3 giving the coordinates$(x0,y0)$of the centre and the radius$r0$of a circle.triangles
is a list of 6 variables giving the vertices coordinates
$(ax,ay,bx,by,cx,cy)$of the triangles to remove from a simple (rectangular or circular) initial window. The triangles may be removed
near the boundary of a rectangular window in order to design a polygonal sampling window, or within a rectangle
or a circle, to delineating holes in the initial sampling window (see Examples). The triangles do not overlap each other, nor overlap boundary
of the initial sampling window. Any polygon (possibly with holes) can be decomposed into contiguous triangles usingtriangulate
.area.swin
,
inside.swin
,
spp
#rectangle of size [0,110] x [0,90]
wr <- swin(c(0,0,110,90))
summary(wr)
plot(wr)
#circle with radius 50 centred on (55,45)
wc <- swin(c(55,45,50))
summary(wc)
plot(wc)
# polygon (diamond shape)
t1 <- c(0,0,55,0,0,45)
t2 <- c(55,0,110,0,110,45)
t3 <- c(0,45,0,90,55,90)
t4 <- c(55,90,110,90,110,45)
wp <- swin(wr, rbind(t1,t2,t3,t4))
summary(wp)
plot(wp)
#rectangle with a hole
h1 <- c(25,45,55,75,85,45)
h2 <- c(25,45,55,15,85,45)
wrh <- swin(wr, rbind(h1,h2))
summary(wrh)
plot(wrh)
#circle with a hole
wch <- swin(wc, rbind(h1,h2))
summary(wch)
plot(wch)
#converting an owin object from spatstat
data(demopat)
demo.swin<-owin2swin(demopat$window)
plot(demo.swin)
Run the code above in your browser using DataLab