# halton.lattice.polygon: Halton lattice inside a 'SpatialPolygon*' object. In SDraw: Spatially Balanced Sample Draws for Spatial Objects

## 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:

• `latticeID`: A unique identifier for every point. ID's are integers numbering points in row-major order from the south.

• `geometryID`: The ID of the polygon in `x` containing each point. The ID of polygons in `x` are `row.names(geometry(x))`.

• Any attributes of the original polygons (in `x`).

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

• `J`: the `J` vector used to construct the lattice. This is either the input `J` or the computed `J` when only `N` is specified.

• `eta`: the `eta` vector used in the lattice.

• `bases`: the bases of the van der Corput sequences used in the lattice, one per dimension.

• `triangular`: Whether the lattice is triangular or square.

• `hl.bbox`: the bounding box surrounding the input `x` object. This is saved because bounding box of the return object is not the same as the bounding box of `x` (i.e., `bbox(return)` `!=` `bbox(x)`).

## Author(s)

Trent McDonald

`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.