Description Usage Arguments Details Value Author(s) See Also Examples
Draws a systematic, or grid, sample from a SpatialPolygons
or
SpatialPolygonsDataFrame
object. Optional parameters control
control the relative spacing in horizontal and vertical directions, whether
a square or triangular grid is produced, and whether the grid baseline has
random orientation.
1  sss.polygon(x, n, spacing = c(1, 1), triangular = FALSE, rand.dir = FALSE)

x 
A 
n 
Sample size. Number of locations to draw from the union of all
polygons contained in 
spacing 
A vector of length 2 containing the RELATIVE spacing of grid points in the horizontal (X) and vertical (Y) directions. See details. 
triangular 
Boolean scaler specifying whether to produce a rectangular
( 
rand.dir 
Either a boolean scaler specifying whether to randomly
orient the
grid's horizontal axis ( 
The projection system of the input shape object (x
) is
not considered. But, a projected coordinate system is necessary to
obtain correct spacing on the ground.
The author STRONGLY recommends converting x
to a UTM coordinate
system prior to calling this function.
Spacing (size and shape of grid cells) is determined by n
and
spacing
. If spacing
is not given,
grid spacing is equal in X and Y directions, which produces square grid
cells. In this case, grid spacing is delta
(= sqrt(A/n)
, where
A
= area of union of all polygons in x
.
Relative shape of grid cells is controlled by the spacing
vector. If
spacing = c(rx, ry)
, spacing in X and Y directions is
spacing*delta/rev(spacing)
, where delta
= sqrt(A/n)
. Conceptually, a square cell of size delta^2
is "stretched" multiplicatively by rx
in the X direction and ry
in the
Y direction. After stretching, the area of each cell remains
delta^2
while the relative lengths of the (rectangular) cell
sides is 1 to (ry/rx)^2
. That is, vertical dimension of each cell
is (ry/rx)^2
times the horizontal dimension. Vice versa, the horizontal
dimension is (rx/ry)^2
times the vertical.
In general, realized sample size is not fixed. Across multiple calls,
realized sample size will not always equal n
. Across an infinite number
of calls, the average sample size will be n
In all cases, the grid is randomly shifted in the X and Y directions, before rotation (if called for). The amount of the random shift is less than the X and Y extent of cells, and is returned as an attribute of the sample.
A SpatialPointsDataFrame
containing locations in the SSS sample,
in rowwise order starting in the south (see sampleID
, row
, col
in returned data frame). Attributes of the sample points (in the
embedded data frame) are
as follows:
sampleID
: A unique identifier for every sample point. For
rectangular grids, sampleID
is incremented west to east by row from
the south. For triangular grids, sampleID
is assigned west to east
to points in every other row from the south. Then,
starts over in the southwest and assigns ID's to previouslyskipped
rows.
row
: Row number of the sampled point in the grid. Row numbers
are the vertical indices of the grid in a direction perpendicular to
the (potentially rotated) main horizontal axis. Cell (1,1) is in
the lower left (southwest) corner of the shape's bounding box.
Thus, row 1 is defined
along the lower (southern) boundary of the shape's bounding box.
Points in row 1 may not be inside the shape and therefore
may not appear in the sample. Consequently, the lowest row appearing
in the sample may not be 1. Visualize row i with
points(samp[samp$row==i,])
.
col
: Column number of the sampled point in the grid. Column
numbers are the horizontal indices of the grid in a direction parallel to
the (potentially rotated) main horizontal axis. Cell (1,1) is in
the lower left (southwest) corner of the shape's bounding box.
Thus, column 1 is defined
along the left (western) boundary of the shape's bounding box.
Points in column 1 may not be inside the shape and therefore
may not appear in the sample. Consequently, the lowest column appearing
in the sample may not be 1. Visualize column i with
points(samp[samp$col==i,])
.
geometryID
: The ID of the polygon in x
which each
sample point falls. 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:
frame
: Name of the input sampling frame.
frame.type
: Type of resource in sampling frame. (i.e., "polygon").
sample.type
: Type of sample drawn. (i.e., "SSS").
spacing.m
: A vector of length 2 giving the dimensions of
cells in units of the coordinates of x
. (e.g., meters). This
is the final delta
computed above. Each cell has size
prod(spacing.m)
= Area / n
.
rand.dir
: The (potentially randomly chosen) direction for the grid's
horizontal axis. This is in radians between pi/4 and pi/4.
rand.dir
= 0 corresponds to no rotation
(i.e., rand.dir = FALSE
).
rand.shift
: The random shift of the grid. This is a vector
of length 2 containing the random shifts in the horizontal and vertical
directions before rotation. The random shift in both directions
is chosen between 0 and the corresponding element of the spacing.m
attribute (described above).
triangular
: TRUE or FALSE depending on whether the output
grid is triangular or rectangular, respectively.
Trent McDonald
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22  # A square grid oriented eastwest
WA.samp < sss.polygon( WA, 100 )
plot( WA )
points( WA.samp )
# A rectangular grid oriented eastwest, with relative spacing c(0.667, 1.5),
# or 1 to 2.25.
WA.samp < sss.polygon( WA, 100, spacing=c(2,3) )
plot( WA )
points( WA.samp )
# A rectangular grid oriented eastwest, with x spacing = 2*(y spacing).
WA.samp < sss.polygon( WA, 100, spacing=c(sqrt(2),1) )
# A rectangular grid, random orientation, with y spacing = 3*(x spacing)
WA.samp < sss.polygon( WA, 100, spacing=c(1,sqrt(3)), rand.dir=TRUE )
# A triangular grid oriented eastwest
WA.samp < sss.polygon( WA, 100, triangular=TRUE )
# A triangular grid oriented eastwest, with relative spacing c(.667,1.5)
WA.samp < sss.polygon( WA, 100, spacing=c(2,3), triangular=TRUE )

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.