This is a question about the R package spatstat
.
The argument win
specifies the spatial region in which the points will be generated. In your example you have specified this region to be a rectangle. You just need to replace this rectangle by the region in which you want the points to be generated.
You can construct spatial regions (objects of class owin
) in many ways. See help(owin)
, or help(spatstat)
for an overview.
In your example, you could build up the shape by forming the union of several rectangles. For example to make a simple cross shape, I could just write
require(spatstat)
A <- owin(c(-1,1), c(-4, 4))
B <- owin(c(-4,4), c(-1,1))
U <- union.owin(A, B)
plot(U)
Another way would be to specify the corners of the polygon shape and use W <- owin(poly=p)
where p = list(x, y)
contains the coordinates of the corners, listed in anticlockwise order without repetition. See help(owin)
.
This is also covered in Section 3.5 of the spatstat book. You can download Chapter 3 for free.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…