Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

stratrand

Stratified random point pattern


Description

Generates a “stratified random” pattern of points in a window, by dividing the window into rectangular tiles and placing k random points in each tile.

Usage

stratrand(window, nx, ny, k = 1)

Arguments

window

A window. An object of class owin, or data in any format acceptable to as.owin().

nx

Number of tiles in each row.

ny

Number of tiles in each column.

k

Number of random points to generate in each tile.

Details

The bounding rectangle of window is divided into a regular nx * ny grid of rectangular tiles. In each tile, k random points are generated independently with a uniform distribution in that tile.

Note that some of these grid points may lie outside the window, if window is not of type "rectangle". The function inside.owin can be used to select those grid points which do lie inside the window. See the examples.

This function is useful in creating dummy points for quadrature schemes (see quadscheme) as well as in simulating random point patterns.

Value

A list with two components x and y, which are numeric vectors giving the coordinates of the random points.

Author(s)

and Rolf Turner r.turner@auckland.ac.nz

See Also

Examples

w <- unit.square()
  xy <- stratrand(w, 10, 10)
  # plot(w)
  # points(xy)

  # polygonal boundary
  bdry <- list(x=c(0.1,0.3,0.7,0.4,0.2),
               y=c(0.1,0.1,0.5,0.7,0.3))
  w <- owin(c(0,1), c(0,1), poly=bdry)
  xy <- stratrand(w, 10, 10, 3)
  # plot(w)
  # points(xy)

  # determine which grid points are inside polygon
  ok <- inside.owin(xy$x, xy$y, w)
  # plot(w)
  # points(xy$x[ok], xy$y[ok])

spatstat.geom

Geometrical Functionality of the 'spatstat' Family

v2.1-0
GPL (>= 2)
Authors
Adrian Baddeley [aut, cre], Rolf Turner [aut], Ege Rubak [aut], Tilman Davies [ctb], Ute Hahn [ctb], Abdollah Jalilian [ctb], Sebastian Meyer [ctb], Suman Rakshit [ctb], Dominic Schuhmacher [ctb], Rasmus Waagepetersen [ctb]
Initial release
2021-04-15

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.