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 unequal probability 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] Continuous:Categorical variable.’
Note that the label changes depending on the ‘Sample Allocation’
selected. Continuous variables associate with numeric variables, while
categorical associate with factor and/or character variables. In all
cases, this variable must be contained in the attribute data of the spatial
object specified in the Shapefile box. For example, for a
Continuous-variable sample, this could be the elevation associated with
every point in the shapefile. This name is case sensitive and must match
that in the shapefile or sp object exactly.
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 ‘Continuous’ relative to the range of a continuous variable in the population; ‘Constant’ across all categories of a categorical variable; and ‘Unequal proportion’ sample sizes within each category of a categorical variable. Note that units in small categories will have lower probabilities of inclusion and may not be represented in small overall sample sizes.
Additionally, observe that selection of the ‘Continuous’ radio button leads to a ‘Continous Variable’ label in the ‘Frame Information’ section of the GUI. Similarly, a ‘Categorical Variable’ label appears on selection of ‘Constant’ or ‘Unequal proportion.’
Specify the sample size as described above for the appropriate allocation scheme.
Sample Allocation & Sample Size
If the allocation scheme is ‘Continous,’ enter one number for ‘Sample Size.’ This number will be distributed among the range based on the values in the provided ‘Continuous Variable.’
If the allocation scheme is ‘Constant,’ enter one number for ‘Sample Size.’ This number will be selected across all categories, with the number of sample points resulting in each category proportional to the number in each level of the provided ‘Categorical Variable.’ The count of all points across all levels then equals the number originally entered.
If the allocation scheme is ‘Unequal Proportion,’ enter a list
of numbers separated by commas for ‘Sample Size.’ If there are
H categories in the frame, specify H numbers, i.e., one number
per category. Order of sample sizes should be the same as the levels of the
categorical variable, as with a factor. In fact, to match sample sizes to
categories, SDrawNPS calls function factor to extract factor
levels of the categorical variable. The order of these levels is the order
of samples sizes in the list. For example, if the categorical variable
contains strings "small" and "big", converting this variable
to a factor generally results in alphabetic ordering of levels, as in
c("big", "small"). In this case, the first number in the specified
list should be the sample size in the "big" category. 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.
unequal.GUI()
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.