Skip to content
Prev 6697 / 29559 Next

Spatstat package: help generating random point pattern with different window

Volkan Kepoglu wrote:
The last line instructs spatstat to generate a Poisson process with an 
**intensity** equal to 100000,
that is, a density of 100000 points ***PER UNIT AREA**.

Your polygonal window sp_owin has an area of 11857425 square units.

This means the expected number of points in the simulated pattern is 
100000 * 11857425 = 1.185743e+12.
That is more than a trillion points.

For a Poisson process, the actual number of points generated is a 
Poisson random variable with mean equal to 1.2 trillion:
      v <- 100000 * 11857425
      n <- rpois(1, v)
      x <- runif(n)
The error message is coming from 'runif' which is refusing to generate 
more than a trillion random numbers:
      Error in runif(n) : invalid arguments
      In addition: Warning message:
      In runif(n) : NAs introduced by coercion

If you wanted to generate approximately 100000 points, set lambda = 
100000/area.owin(sp_owin) in the call to rpoispp.
If you wanted to generate exactly 100000 points, use runifpoint(100000, 
win=sp_owin).

Adrian Baddeley