Description Usage Details Value Required Inputs Optional Inputs Dialog Buttons Author(s) References See Also Examples
Initiates a dialog box via a GUI to select stratified samples from 2-D resources.
1 |
This routine is intended to be called from the SDrawNPS
menu,
but it can also be called from the command line in non-interactive
environments, such as RStudio. This routine uses the RGtk2
package
windowing capabilities to construct a pop-up dialog box, or GUI. In the
dialog box, users specify at least the required input parameters, then
press the ‘Run’ button to draw the sample.
On submission, the GUI internally packages its inputs, processes the
necessary shapefile, and executes the spsurvey
-package grts
function. All SDrawNPS
GUI submissions utilizing the GRTS sampling
methodology lead to the creation of a text-based log file, which records
all code utilized. The log file thus serves as a historical record
containing sampling information, including the random seed utilized. It
also serves as a tool for enhancing methodological understanding.
See ‘References’ for additional resources.
A SpatialDesign
(see the spsurvey
package) object with
the name specified by the user in the GUI's Sample's R
name
box. This object contains the sampling design specifications, the
selected sample points in GRTS order, coordinates, and projection
information. Sample objects are stored in the current workspace, while any
export files, including a txt
log of the commands utilized to
generate the sample, are saved to the file directory specified via
getwd
.
Any maps drawn during the sampling process must be saved before R is
closed. See dev.copy
, jpg
, and other graphics device
functions.
Frame Information
Select GRTS
as the ‘Sample Type’ in the top drop-down
list. The other sampling types are not currently available.
Specify the shapefile or SpatialPoints*
, SpatialLines*
,
or SpatialPolygons*
package-sp
object that constitutes the
sample frame in the Shapefile
box, or click ‘Browse’ to
browse for a shapefile with a .shp
extension. When specifying the
name of a shapefile via use of the input box, do not include the
.shp
extension and recognize that all files associated with the
shapefile must reside in the current working directory, i.e., the one
returned by getwd
. Following selection of a spatial object or
shapefile, click the ‘Inspect Frame’ button to plot it and list
variables associated with its attribute data. This is a good way to
determine the study area boundary.
Specify the name of the stratification variable. This variable must
be contained in the attribute data of the spatial object specified in the
Shapefile
box. For example, this could be an elevational class
associated with every point in the shapefile. This name is case sensitive
and must match that in the shapefile or sp
object exactly. Constant
values of this variable define the strata.
Specify the sample's R object name. The output will be a
SpatialDesign
object created via the spsurvey
package, and
contains the sampling design specifications and selected sample points in
GRTS order, along with spatial coordinates and projection information.
Specify the ‘Sample Allocation’ scheme. Available options include ‘Proportional to Size’ relative to the size of each stratum in the population; ‘Constant’ or the same number in all strata; and ‘User-specified’ sample sizes within each stratum. Note that units in small strata will have lower probabilities of inclusion and may not be represented in small overall sample sizes.
Specify the sample size as described above for the appropriate allocation scheme.
Sample Allocation & Sample Size
If the allocation scheme is ‘Proportional to Size,’ enter one number for ‘Sample Size.’ This number will be distributed among strata based on the relative number of points, length of lines, or area of polygons in each stratum.
If the allocation scheme is ‘Constant,’ enter one number for
‘Sample Size.’ This number will be selected from each stratum. For
example, if 50
is specified, 50 points will be selected from objects
in each stratum.
If the allocation scheme is ‘User-specified,’ enter a list of
numbers separated by commas for ‘Sample Size.’ If there are H
strata in the frame, specify H numbers, i.e., one number per stratum.
Order of sample sizes should be the same as the levels of the
stratification variable, as with a factor. In fact, to match sample sizes
to strata, SDrawNPS
calls function factor
to extract factor
levels of the strata variable. The order of these levels is the order of
samples sizes in the list. For example, if the strata variable contains
strings "low"
and "high"
, converting this variable to a
factor generally results in alphabetic ordering of levels, as in
c("high", "low")
. In this case, the first number in the specified
list should be the sample size in the "high"
stratum. The default
ordering of levels when vectors are converted to factors is alphabetic,
unless global options have changed.
The ‘Random number seed.’ When specified, the seed may be used
to recreate the sample. When not specified, i.e., the box is left blank, a
random seed is selected against the current time. See set.seed
. In
both cases, the seed ultimately utilized is recorded in both the resulting
log text file and R Console. Recording the seed allows for the easy
redrawing of samples if lost, or if more sites are needed. Any integer
value is acceptable as the random number seed.
The number of oversample points, as encompassed via the ‘Over sample, each strata’ box, can be specified within each stratum. Oversample points are listed after the main sample points in the GRTS design file, i.e., the resulting sample R output object. They can also be identified in the ‘panel’ variable of the sample output. Apply caution when specifying oversample points, as large oversamples can cause samples to tend toward a proportional-to-size allocation even when other allocations are specified.
‘Inspect Frame.’ After specifying the shapefile or sp
object name, pressing the ‘Inspect Frame’ button plots the
shapefile. It also lists the variables and their class in the
shapefile's attribute data. After drawing a sample, the
‘Inspect Frame’ button plots the study area, along with sampled
points.
‘Run.’ After specifying all required and optional inputs, the
‘Run’ button draws the sample. The .GlobalEnv
workspace
holds the resulting SpatialDesign
object with the name specified via
the GUI Sample's R name
box. A confirmation dialog appears
following completion of the draw. Large samples may require several tens of
minutes for completion.
‘Plot Sample.’ Following sampling, the ‘Plot Sample’ button displays the sampled points on the sampling frame.
‘Tabulate Sample.’ Following sampling, display the GRTS design file in a tabular format. The GRTS design file contains information on each sampled unit, such as coordinates, and design variables, e.g., stratum or multi-density category. It also contains design weights.
‘Export.’ Following sampling, the ‘Export’ button
prompts the user to save sampling results via a pop-up dialog box. The
sample can be exported as an ArcGIS shapefile (.SHP
); Comma
Separated (.CSV
); Google Earth (.KML
); or Garmin format
(.GPX
) file.
Shapefiles actually consist of several files with different extensions.
Because of this, do not include the .SHP
extension in the
Name
field of the pop-up when exporting to a shapefile.
‘Done.’ Dismisses the GUI dialog box, leaving any sample
objects in the .GlobalEnv
workspace.
Trent McDonald (tmcdonald@west-inc.com) and Jason Mitchell (jmitchell@west-inc.com)
Stevens, D. L. and A. R. Olsen (2004). Spatially balanced sampling of natural resources. Journal of the American Statistical Association 99, 262-278.
Kincaid, T. (2015). GRTS Survey Designs for an Area Resource. Accessed
online May 6, 2016.
https://cran.r-project.org/web/packages/spsurvey/vignettes/Area_Design.pdf
.
Starcevich L. A., DiDonato G., McDonald T., Mitchell, J. (2016). A GRTS User's Manual for the SDrawNPS Package: A graphical user interface for Generalized Random Tessellation Stratified (GRTS) sampling and estimation. National Park Service, U.S. Department of the Interior. Natural Resource Report NPS/XXXX/NRR—20XX/XXX.
1 2 3 | # Open a GUI for stratified GRTS sampling.
stratified.GUI()
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.