halton.frame: Construct a Halton sampling frame.

Description Usage Arguments Value Author(s) See Also Examples

View source: R/halton.frame.r

Description

Makes a Halton frame from a set of points that have their Halton indices attached. This function identifies points in the same Halton box, and randomly adds Halton cycles to geographically separate nearby points. The frame is then sorted by the new frame indices for sampling.

Usage

1
halton.frame(x, index.name = attr(x, "index.name"), order.name = "HaltonOrder")

Arguments

x

Either a data frame or a SpatialPointsDataFrame object. In particular, the output of halton.indices is acceptable. The data frame, or data frame of the SpatialPointsDataFrame, must contain the Halton indices, which is assumed to be named attr(x, "index.name"). The default name for this column when using output from halton.indices is HaltonIndex. Each row of the data frame is a sampling unit to be included in the frame, and the Halton index of the unit is the Halton box the unit falls in. A SpatialPoints object without the data frame is not acceptable.

index.name

Name of the Halton index column in the input object. This names the column of x containing the index of the Halton box that contains the point represented on that row of x. In reality, this could be any ordering for the rows in x. Duplicate values of this column are randomly moved to the end of the frame. If index.name is missing (the default), x is assumed to have an attribute names index.name

order.name

Name of the Halton order column in the output object. See description of returned object. This parameter is saved as an attribute of the output object.

Value

A data frame or SpatialPointsDataFrame suitable for use as a sampling frame. The data frame, or attributes of the points, contain a new index column separating points in the same Halton box, and the output is sorted by this new index. Returned object has the following attributes,

Author(s)

Trent McDonald

See Also

halton.indices

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
# The following is equivalent to hal.point(WA.cities,20,J=c(6,3))

# Define Halton lattice
attr(WA.cities,"J") <- c(6,3)
attr(WA.cities,"bases") <- c(2,3)

# Add tiny amount to right and top of bounding box because Halton boxes are 
# closed on the left and bottom.  This includes points exactly on top and right 
# bounding lines.
attr(WA.cities,"hl.bbox") <- bbox(WA.cities) + c(0,0,1,1) 

# Compute Halton indices
frame <- halton.indices( WA.cities )

# Separate points in frame that are in same box
frame <- halton.frame( frame )

# Draw sample of size 20
n <- 20
random.start <- floor( runif(1,0,nrow(frame)-1 ) )
samp <- frame[ ( ((0:(n-1))+random.start) %% nrow(frame) ) + 1, ]

SDraw documentation built on July 8, 2020, 6:23 p.m.