Learn R Programming

SDraw (version 2.1.13)

sss.point: Draw a Simple Systematic Sample (SSS) from a point resource or finite population frame.

Description

Draw a systematic sample from a SpatialPoints* object or a data.frame. SpatialPoints* objects can represent point resources in 2-dimensional space, such as towns, event locations, or grid cell centers.

Usage

sss.point(x, n)

Arguments

x

A SpatialLines, SpatialLinesDataFrame, or data.frame object.

n

Sample size. Number of points to draw from the set of all points in x. If n exceeds the number of units (= number of rows in data.frame(x)), a census is taken (i.e., x is returned).

Value

If input x inherits from a the SpatialPointsDataFrame class, a SpatialPointsDataFrame object containing locations in the sample is returned. If input x is a data.frame, a data.frame is returned. Attributes of the returned sample points are:

  • sampleID: A unique identifier for every sample point. sampleID starts with 1 at the first point and increments by one for each.

  • If x inherits from SpatialPoints, returned points have attribute geometryID -- the ID (= row.names(x) ) of the sampled point.

  • Any attributes (columns) associated with the input points (rows).

Additional attributes of the output object are:

  • frame: Name of the input sampling frame (i.e., x).

  • frame.type: Type of resource in sampling frame. (i.e., "point").

  • sample.type: Type of sample drawn. (i.e., "SSS").

  • random.start: The random start for the systematic sample.

Using these additional attributes, one could reconstruct the sample.

Details

The points in x are systematically sampled in the order they appear. That is, the sampling frame (i.e., data.frame(x)) is not re-ordered prior to sampling. Each row in the frame represents a point or sample unit, and rows are sampled systematically starting with row 1. To draw a systematic sample across the range of an attribute, say attribute \(y\), sort x by \(y\) prior to calling this routine (e.g,. sss.point( x[order(x$y),], n )).

This routine draws fixed size systematic samples. Many systematic sampling procedure produce variable size samples. Conceptually, the sample procedure is:

  1. Each sample unit (= row of sample frame) is associated with a line segment. Assuming there are \(N\) units in the frame (\(N\) = nrow(x)), each line segment has length \(n/N\), where \(n\) is the input desired sample size.

  2. Line segments are placed end-to-end, starting at 0, in the order in which their associated unit appears in the frame.

  3. To start the systematic sample, the routine chooses a random number between 0 and 1. Let this random number be \(m\).

  4. The sample units associated with the line segments containing the numbers \(m + i\) for \(i\) = 0,1,...,(\(n-1\)), are selected for the sample.

See Also

sss.polygon, sss.line, sdraw

Examples

Run this code
# NOT RUN {
# Draw systematic sample across range of population
WA.samp <- sss.point( WA.cities[order(WA.cities$POP_2010),], 100 )   
plot( WA.cities )
points( WA.samp, col="red", pch=16 )

# Draw systematic sample from data frame
df <- data.frame( a=1:100, b=runif(100) )
samp <- sss.point( df, 5 )   

# Equivalent to simple random sample: randomly sort frame.
samp <- sss.point( df[order(df$b),], 5 )

# }

Run the code above in your browser using DataLab