halton.lattice.polygon: Halton lattice inside a 'SpatialPolygon*' object.

Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/halton.lattice.polygon.r

Description

Constructs a lattice of Halton boxes (a Halton lattice) inside a SpatialPolygons or SpatialPolygonsDataFrame object. This is a wrapper for halton.lattice, which does all the hard work.

Usage

1
2
halton.lattice.polygon(x, N = 10000, J = NULL, eta = c(1, 1),
  triangular = FALSE, bases = c(2, 3))

Arguments

x

A SpatialPolygons or SpatialPolygonsDataFrame object.

N

Approximate number of points to place in the lattice. If J is specified, it takes precedence. If J is NULL, the algorithm attempts to place N points in the bounding box using Halton boxes that are as close to square as possible. This N is not exact, but is a target.

J

A 2X1 vector of base powers which determines the size and shape of the Halton boxes. See additional description in help for hal.polygon function.

eta

A 2X1 vector of the number of points to add inside each Halton box. e.g., if eta = c(3,2), a small grid of 3 by 2 points is added inside each Halton box. eta[1] is for the horizontal dimension, eta[2] is for the vertical dimension.

triangular

boolean, if TRUE, construct a triangular grid. If FALSE, construct rectangular grid. See help for hal.polygon.

bases

A 2X1 vector of Halton bases. These must be co-prime.

Details

This routine is called internally by hal.polygon, and is not normally called by the user.

Value

A SpatialPointsDataFrame containing locations in the Halton lattice

Attributes of the points are:

Additional attributes of the output object, beyond those which make it a SpatialPointsDataFrame, are:

Author(s)

Trent McDonald

See Also

hal.polygon, halton.lattice

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
# Take and plot Halton lattice to illustrate
WA.hgrid <- halton.lattice.polygon( WA, J=c(3,2), eta=c(3,2), triangular=TRUE )
plot(WA)
points(WA.hgrid, pch=16, cex=.5, col="red" )

# Plot the Halton boxes
tmp.J <- attr(WA.hgrid,"J")
tmp.b <- attr(WA.hgrid,"bases")
tmp.bb <- attr(WA.hgrid,"hl.bbox")

for(d in 1:2){
  tmp2 <- tmp.bb[d,1] + (0:(tmp.b[d]^tmp.J[d]))*(diff(tmp.bb[d,]))/(tmp.b[d]^tmp.J[d])
  if( d == 1){
      abline(v=tmp2, col="blue")
  } else{
      abline(h=tmp2, col="blue")
  }
}

# To explore, re-run the above changing J, eta, and triangular, 

SDraw documentation built on May 29, 2017, 6:14 p.m.