Description Usage Arguments Details Value Author(s) See Also Examples
View source: R/halton.lattice.polygon.r
Constructs a lattice of Halton boxes (a Halton lattice) inside a
SpatialPolygons
or Spatial
Polygons
DataFrame
object. This is a wrapper for
halton.lattice
, which does all the hard work.
1 2 3 4 5 6 7 8 | halton.lattice.polygon(
x,
N = 10000,
J = NULL,
eta = c(1, 1),
triangular = FALSE,
bases = c(2, 3)
)
|
x |
A |
N |
Approximate number of points to place in the lattice. If |
J |
A 2X1 vector of base powers which determines the size and shape
of the Halton boxes. See additional description in help for
|
eta |
A 2X1 vector of the number of points to add inside each Halton box.
e.g., if |
triangular |
boolean, if TRUE, construct a triangular grid.
If FALSE, construct rectangular grid. See help for |
bases |
A 2X1 vector of Halton bases. These must be co-prime. |
This routine is called internally by hip.polygon
, and is not
normally called by the user.
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)
).
Trent McDonald
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,
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.