Area Design

Tom Kincaid

2019-08-29

Preliminaries

This document presents example GRTS survey designs for an area resource. The area resource used in the designs is Omernik level 3 ecoregions within Utah. Four survey designs will be presented: (1) an unstratified, equal probability design; (2) an unstratified, unequal probability design; (3) a stratified, equal probability design; and (4) an unstratified, unequal probability design with an oversample and a panel structure for survey over time. The sampling frame used for the survey designs is contained in either an ESRI shapefile, an sf package object, or an sp package object. The frame contains the coordinates for a set of polygons that define the area resource in addition to attribute data associated with the polygons. The coordinate system for the set of points in the sampling frame is an equal area projection rather than latitude and longitude. An equal area projection is used so that calculation of distance between points is valid.

The initial step is to use the library function to load the spsurvey package. After the package is loaded, a message is printed to the R console indicating that the spsurvey package was loaded successfully.

Load the spsurvey package:

library(spsurvey)

Read the sf object

For creating a survey design using the spsurvey package, the standard form of input regarding the resource is a simple features (sf) object. An sf data set for creating the survey designs in this vignette is included in the data directory of the package. The data function is used to load the data set stored in the data directory into an object named UT_ecoregions. Note that sf objects loaded from the data sets in the data directory are stored in a format that is defined in the sf package. See documentation for the sf package for additional information regarding format of those objects.

data(UT_ecoregions)

Attribute data

The ecoregion attribute will be used to define stratum codes and unequal selection probability (multidensity) categories for the survey designs. Ecoregion is contained in a variable named “Level3_Nam” and includes seven unique values. Frame area is summarized for the ecoregion attribute. Note that ecoregion area measured in hectares is contained in the variable named “Area_ha”. The tapply function is used to calculate total area for each ecoregion. The addmargins function is applied to the output from tapply to calculate total area for all ecoregions, and the round function is used to round value to whole numbers. Finally, the resulting table is displayed.

Display the initial six features in the sf object:

head(UT_ecoregions)
#> Simple feature collection with 6 features and 3 fields
#> geometry type:  MULTIPOLYGON
#> dimension:      XY
#> bbox:           xmin: -1574643 ymin: 1629173 xmax: -1085382 ymax: 2250764
#> epsg (SRID):    5070
#> proj4string:    +proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=23 +lon_0=-96 +x_0=0 +y_0=0 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs
#>   Level3                  Level3_Nam     Area_ha
#> 1     80    Northern Basin and Range 1.42202e+11
#> 2     18               Wyoming Basin 1.33312e+11
#> 3     13     Central Basin and Range 3.09949e+11
#> 4     19 Wasatch and Uinta Mountains 4.47240e+10
#> 5     20           Colorado Plateaus 1.26379e+11
#> 6     21            Southern Rockies 5.40909e+08
#>                         geometry
#> 1 MULTIPOLYGON (((-1317868 22...
#> 2 MULTIPOLYGON (((-1128931 20...
#> 3 MULTIPOLYGON (((-1487359 21...
#> 4 MULTIPOLYGON (((-1288590 22...
#> 5 MULTIPOLYGON (((-1087925 20...
#> 6 MULTIPOLYGON (((-1133832 18...

Summarize frame area by ecoregion:

temp <- with(UT_ecoregions, tapply(Area_ha, Level3_Nam, sum))
temp <- round(addmargins(temp), 0)
temp
#>     Central Basin and Range           Colorado Plateaus 
#>                309949000000                126379000000 
#>      Mojave Basin and Range    Northern Basin and Range 
#>                129599000000                142202000000 
#>            Southern Rockies Wasatch and Uinta Mountains 
#>                   946443000                 45693759000 
#>               Wyoming Basin                         Sum 
#>                133312000000                888081202000

The seven ecoregions in Utah are displayed below. Ecoregions are used during creation of several of the survey designs described in this vignette.

Location of the seven ecoregions in Utah.

Location of the seven ecoregions in Utah.

Unstratified, equal probability, GRTS survey design

The first survey design is an unstratified, equal probability design. The set.seed function is called so that, if necessary, the designs can be replicated.

The initial step is to create a list named Equaldsgn that contains information for specifying the survey design. Since the survey design is unstratified, the list contains a single item named “None” that also is a list. The “None” list includes two items: panel, which is used to specify the sample size for each panel, and seltype, which is used to input the type of random selection for the design. For this example, panel is assigned a single value named “PanelOne” that is set equal to 115, and seltype is assigned the value “Equal”, which indicates equal probability selection.

The grts function in the spsurvey package is called to select the survey design. The following arguments are included in the call to grts: (1) design: the named list of stratum design specifications, which is assigned the Equaldsgn list; (2) DesignID: name for the design, which is used to create a site ID for each site and is assigned the value “EQUAL”; (3) type.frame: the type of frame, which is assigned the value “area” to indicate an area resource; (4) src.frame: source of the frame, which is assigned the value “sf.object” to indicate an sf object frame; (5) sf.object: the sf object, which is assigned the value UT_ecoregions; and (6) shapefile: option to create a shapefile containing the survey design information, which is assigned FALSE.

During execution of the grts function, messages are printed that indicate the initial number of hierarchical levels used for the GRTS grid, the current number of levels, and the final number of levels. The set of messages is printed for each stratum, and is labeled with the stratum name. For this example, the set of messages is labeled “None”, i.e., the name used in the Equaldsgn list. Upon completion of the call to grts, the initial six sites for the survey design and a design summary are printed. The output object created by the grts function is assigned class “SpatialDesign”. The design summary is created using the summary method for that class. In addition to summary, a plot method is available for the SpatialDesign class. For assistance using the summary and plot methods, see documentation for “SpatialDesign-class” on the R help page for spsurvey.

Call the set.seed function so that the design can be replicated:

set.seed(4447864)

Create the design list:

Equaldsgn <- list(None=list(panel=c(PanelOne=50), seltype="Equal"))

Select the sample:

Equalsites <- grts(design=Equaldsgn,
                   DesignID="EQUAL",
                   type.frame="area",
                   src.frame="sf.object",
                   sf.object=UT_ecoregions,
                   shapefile=FALSE)
#> 
#> Stratum: None 
#> Current number of levels: 3 
#> Current number of levels: 4 
#> Final number of levels: 4

Print the initial six lines of the survey design:

head(Equalsites)
#>           coordinates   siteID   xcoord  ycoord mdcaty        wgt stratum
#> 1 (-1256763, 2115951) EQUAL-01 -1256763 2115951  Equal 4396596870    None
#> 2 (-1259924, 2079541) EQUAL-02 -1259924 2079541  Equal 4396596870    None
#> 3 (-1242538, 1721144) EQUAL-03 -1242538 1721144  Equal 4396596870    None
#> 4 (-1464103, 2224971) EQUAL-04 -1464103 2224971  Equal 4396596870    None
#> 5 (-1106808, 2023967) EQUAL-05 -1106808 2023967  Equal 4396596870    None
#> 6 (-1393773, 2103455) EQUAL-06 -1393773 2103455  Equal 4396596870    None
#>      panel EvalStatus EvalReason Level3                  Level3_Nam
#> 1 PanelOne    NotEval                19 Wasatch and Uinta Mountains
#> 2 PanelOne    NotEval                19 Wasatch and Uinta Mountains
#> 3 PanelOne    NotEval                20           Colorado Plateaus
#> 4 PanelOne    NotEval                80    Northern Basin and Range
#> 5 PanelOne    NotEval                20           Colorado Plateaus
#> 6 PanelOne    NotEval                13     Central Basin and Range
#>       Area_ha
#> 1 4.47240e+10
#> 2 4.47240e+10
#> 3 1.26379e+11
#> 4 1.42202e+11
#> 5 1.26379e+11
#> 6 3.09949e+11

Print the survey design summary:

summary(Equalsites)
#> 
#> 
#> Design Summary: Number of Sites
#> 
#> stratum
#> None  Sum 
#>   50   50

Unstratified, unequal probability, GRTS survey design

The second survey design is an unstratified, unequal probability design. Ecoregions are used to identify multidensity categories. List Unequaldsgn is assigned design specifications. Since the survey design is unstratified, Unequaldsgn includes a single list named “None” that contains three items: panel, seltype, and caty.n. The value for panel is the same as for the equal probability design, and seltype is assigned “Unequal” to indicate unequal selection probabilities. The third item, caty.n, assigns sample sizes for each of seven multidensity categories, where ecoregion names are used as the categories. Note that the sum of sample sizes provided in caty.n must equal the value in panel.

For this survey design, a shapefile will be used as the sampling frame. The sf package function st_write is used to create the shapefile. The following arguments are included in the call to grts: (1) design: assigned the Unequaldsgn list; (2) DesignID: assigned the value “UNEQUAL”; (3) type.frame: assigned the value “area”; (4) src.frame: assigned the value “shapefile”; (5) in.shape: assigned the value “UT_ecoregions.shp”; (6) mdcaty: name of the column in the attributes data frame that identifies the unequal probability category for each element in the frame, which is assigned the value “level3_nam”; and (7) shapefile: assigned the value FALSE. Upon completion of the call to grts, the initial six sites for the survey design and a design summary are printed.

st_write(UT_ecoregions, "UT_ecoregions.shp", quiet = TRUE, delete_dsn = TRUE)
#> Warning in CPL_write_ogr(obj, dsn, layer, driver,
#> as.character(dataset_options), : GDAL Error 1: UT_ecoregions.shp does not
#> appear to be a file or directory.
#> Warning in CPL_write_ogr(obj, dsn, layer, driver,
#> as.character(dataset_options), : GDAL Message 1: Value 142202000000 of
#> field Area_ha of feature 0 not successfully written. Possibly due to too
#> larger number with respect to field width
#> Warning in CPL_write_ogr(obj, dsn, layer, driver,
#> as.character(dataset_options), : GDAL Message 1: Value 133312000000 of
#> field Area_ha of feature 1 not successfully written. Possibly due to too
#> larger number with respect to field width
#> Warning in CPL_write_ogr(obj, dsn, layer, driver,
#> as.character(dataset_options), : GDAL Message 1: Value 309949000000 of
#> field Area_ha of feature 2 not successfully written. Possibly due to too
#> larger number with respect to field width
#> Warning in CPL_write_ogr(obj, dsn, layer, driver,
#> as.character(dataset_options), : GDAL Message 1: Value 44724000000 of field
#> Area_ha of feature 3 not successfully written. Possibly due to too larger
#> number with respect to field width
#> Warning in CPL_write_ogr(obj, dsn, layer, driver,
#> as.character(dataset_options), : GDAL Message 1: Value 126379000000 of
#> field Area_ha of feature 4 not successfully written. Possibly due to too
#> larger number with respect to field width
#> Warning in CPL_write_ogr(obj, dsn, layer, driver,
#> as.character(dataset_options), : GDAL Message 1: Value 540909000 of field
#> Area_ha of feature 5 not successfully written. Possibly due to too larger
#> number with respect to field width
#> Warning in CPL_write_ogr(obj, dsn, layer, driver,
#> as.character(dataset_options), : GDAL Message 1: Value 129599000000 of
#> field Area_ha of feature 6 not successfully written. Possibly due to too
#> larger number with respect to field width
#> Warning in CPL_write_ogr(obj, dsn, layer, driver,
#> as.character(dataset_options), : GDAL Message 1: Value 343657000 of field
#> Area_ha of feature 7 not successfully written. Possibly due to too larger
#> number with respect to field width
#> Warning in CPL_write_ogr(obj, dsn, layer, driver,
#> as.character(dataset_options), : GDAL Message 1: Value 626102000 of field
#> Area_ha of feature 8 not successfully written. Possibly due to too larger
#> number with respect to field width
#> Warning in CPL_write_ogr(obj, dsn, layer, driver,
#> as.character(dataset_options), : GDAL Message 1: Value 405534000 of field
#> Area_ha of feature 9 not successfully written. Possibly due to too larger
#> number with respect to field width

Create the design list:

Unequaldsgn <- list(None=list(panel=c(PanelOne=50),
                              seltype="Unequal",
                              caty.n=c("Central Basin and Range"=10,
                                       "Colorado Plateaus"=10,
                                       "Mojave Basin and Range"=5,
                                       "Northern Basin and Range"=5,
                                       "Southern Rockies"=5,
                                       "Wasatch and Uinta Mountains"=10,
                                       "Wyoming Basin"=5)))

Select the sample:

Unequalsites <- grts(design=Unequaldsgn,
                     DesignID="UNEQUAL",
                     type.frame="area",
                     src.frame="shapefile",
                     in.shape="UT_ecoregions.shp",
                     mdcaty="Level3_Nam",                                   
                     shapefile=FALSE)
#> 
#> Stratum: None 
#> Current number of levels: 3 
#> Current number of levels: 5 
#> Current number of levels: 6 
#> Final number of levels: 6

Print the initial six lines of the survey design:

head(Unequalsites)
#>           coordinates     siteID   xcoord  ycoord                  mdcaty
#> 1 (-1131245, 1803769) UNEQUAL-01 -1131245 1803769        Southern Rockies
#> 2 (-1331075, 1995836) UNEQUAL-02 -1331075 1995836 Central Basin and Range
#> 3 (-1246225, 2210607) UNEQUAL-03 -1246225 2210607           Wyoming Basin
#> 4 (-1528698, 1740367) UNEQUAL-04 -1528698 1740367 Central Basin and Range
#> 5 (-1141665, 1730727) UNEQUAL-05 -1141665 1730727       Colorado Plateaus
#> 6 (-1249301, 1659709) UNEQUAL-06 -1249301 1659709       Colorado Plateaus
#>          wgt stratum    panel EvalStatus EvalReason Level3     Area_ha
#> 1  189288683    None PanelOne    NotEval                21 5.40909e+08
#> 2 8206454636    None PanelOne    NotEval                13 3.09949e+11
#> 3  582117660    None PanelOne    NotEval                18 1.33312e+11
#> 4 8206454636    None PanelOne    NotEval                13 3.09949e+11
#> 5 8579716309    None PanelOne    NotEval                20 1.26379e+11
#> 6 8579716309    None PanelOne    NotEval                20 1.26379e+11

Print the survey design summary:

summary(Unequalsites)
#> Design Summary: Number of Sites Classified by mdcaty (Multidensity Category)
#> 
#> mdcaty
#>     Central Basin and Range           Colorado Plateaus 
#>                          12                           8 
#>      Mojave Basin and Range    Northern Basin and Range 
#>                           3                           5 
#>            Southern Rockies Wasatch and Uinta Mountains 
#>                           5                          13 
#>               Wyoming Basin                         Sum 
#>                           4                          50

Stratified, equal probability, GRTS survey design

The third survey design is a stratified, equal probability design. Ecoregions are used to identify strata. List Stratdsgn is assigned design specifications. The ecoregion attribute is used to identify strata. Stratdsgn includes seven lists, one for each stratum. The names for the lists match the levels of the stratum variable, i.e., the unique values of the ecoregion attribute. Each list in Stratdsgn contains two items: panel and seltype. The value for panel is the same as for the equal probability design, and seltype is assigned “Equal”.

For this survey design, an sp package object will be used as the sampling frame. The sf package function as_Spatial is used to create an sp object named UT_ecoregions_sp. The following arguments are included in the call to grts: (1) design: assigned the Stratdsgn list; (2) DesignID: assigned the value “STRATIFIED”; (3) type.frame: assigned the value “area”; (4) src.frame: assigned the value “sp.object” to indicate that the sampling frame is provided by an sp object; (5) sp.object: the sp object, which is assigned the UT_ecoregions_sp object; (6) stratum: name of the column in the attributes data frame that identifies the stratum code for each element in the frame, which is assigned the value “level3_nam”; and (7) shapefile: assigned the value FALSE. Upon completion of the call to grts, the initial six sites for the survey design and a design summary are printed.

Create the sp object:

UT_ecoregions_sp <- as_Spatial(UT_ecoregions)

Create the design list:

Stratdsgn <- list("Central Basin and Range"=list(panel=c(PanelOne=10),
                                                 seltype="Equal"),
                  "Colorado Plateaus"=list(panel=c(PanelOne=10),
                                           seltype="Equal"),
                  "Mojave Basin and Range"=list(panel=c(PanelOne=5),
                                                seltype="Equal"),
                  "Northern Basin and Range"=list(panel=c(PanelOne=5),
                                                  seltype="Equal"),
                  "Southern Rockies"=list(panel=c(PanelOne=5),
                                          seltype="Equal"),
                  "Wasatch and Uinta Mountains"=list(panel=c(PanelOne=10),
                                                     seltype="Equal"),
                  "Wyoming Basin"=list(panel=c(PanelOne=5),
                                       seltype="Equal"))

Select the sample:

Stratsites <- grts(design=Stratdsgn,
                   DesignID="STRATIFIED",
                   type.frame="area",
                   src.frame="sp.object",
                   sp.object=UT_ecoregions_sp,
                   stratum="Level3_Nam",                                    
                   shapefile=FALSE)
#> 
#> Stratum: Central Basin and Range 
#> Current number of levels: 2 
#> Current number of levels: 3 
#> Final number of levels: 3 
#> 
#> Stratum: Colorado Plateaus 
#> Current number of levels: 2 
#> Current number of levels: 3 
#> Final number of levels: 3 
#> 
#> Stratum: Mojave Basin and Range 
#> Current number of levels: 2 
#> Final number of levels: 2 
#> 
#> Stratum: Northern Basin and Range 
#> Current number of levels: 2 
#> Current number of levels: 3 
#> Final number of levels: 3 
#> 
#> Stratum: Southern Rockies 
#> Current number of levels: 2 
#> Current number of levels: 3 
#> Final number of levels: 3 
#> 
#> Stratum: Wasatch and Uinta Mountains 
#> Current number of levels: 2 
#> Current number of levels: 3 
#> Current number of levels: 4 
#> Final number of levels: 4 
#> 
#> Stratum: Wyoming Basin 
#> Current number of levels: 2 
#> Current number of levels: 3 
#> Final number of levels: 3

Print the initial six lines of the survey design:

head(Stratsites)
#>           coordinates        siteID   xcoord  ycoord mdcaty        wgt
#> 1 (-1390827, 2218435) STRATIFIED-01 -1390827 2218435  Equal 8206454636
#> 2 (-1325403, 2069290) STRATIFIED-02 -1325403 2069290  Equal 8206454636
#> 3 (-1433524, 2001613) STRATIFIED-03 -1433524 2001613  Equal 8206454636
#> 4 (-1350645, 1911696) STRATIFIED-04 -1350645 1911696  Equal 8206454636
#> 5 (-1370640, 2042581) STRATIFIED-05 -1370640 2042581  Equal 8206454636
#> 6 (-1474194, 1777677) STRATIFIED-06 -1474194 1777677  Equal 8206454636
#>                   stratum    panel EvalStatus EvalReason Level3
#> 1 Central Basin and Range PanelOne    NotEval                13
#> 2 Central Basin and Range PanelOne    NotEval                13
#> 3 Central Basin and Range PanelOne    NotEval                13
#> 4 Central Basin and Range PanelOne    NotEval                13
#> 5 Central Basin and Range PanelOne    NotEval                13
#> 6 Central Basin and Range PanelOne    NotEval                13
#>       Area_ha
#> 1 3.09949e+11
#> 2 3.09949e+11
#> 3 3.09949e+11
#> 4 3.09949e+11
#> 5 3.09949e+11
#> 6 3.09949e+11

Print the survey design summary:

summary(Stratsites)
#> 
#> 
#> Design Summary: Number of Sites
#> 
#> stratum
#>     Central Basin and Range           Colorado Plateaus 
#>                          10                          10 
#>      Mojave Basin and Range    Northern Basin and Range 
#>                           5                           5 
#>            Southern Rockies Wasatch and Uinta Mountains 
#>                           5                          10 
#>               Wyoming Basin                         Sum 
#>                           5                          50

Unstratified, unequal probability, GRTS survey design with an oversample and a panel structure for survey over time

The fourth survey design is an unstratified, unequal probability design with an oversample and a panel structure for survey over time. List Paneldsgn is assigned design specifications. Since the survey design is unstratified, Paneldsgn includes a single list named “None” that contains four items: panel, seltype, caty.n, and over. A vector identifying sample sizes for five panels is assigned to panel. The value “Unequal” is assigned to seltype, which indicates unequal selection probabilities. The third item, caty.n, assigns sample sizes for each of seven multidensity categories, where ecoregion names are used as the categories. Note that the sum of sample sizes provided in caty.n must equal the sum of sample sizes in panel. The value 100 is assigned to over, which specifies an oversample of 100 sites. An oversample is replacement sites for the survey design. The grts function attempts to distribute the oversample proportionately among sample sizes for the multidensity categories. If the oversample proportion for one or more categories is not a whole number, a warning message is printed and the proportion is rounded to the next higher integer. For this example, the oversample is not proportionate to the category sample sizes, and the warning message is printed by calling the warnings function.

For this survey design, an sf object will be used as the sampling frame. The following arguments are included in the call to grts: (1) design: assigned the Paneldsgn list; (2) DesignID: assigned the value “UNEQUAL”; (3) type.frame: assigned the value “area”; (4) src.frame: assigned the value “sf.object”; (5) sf.object: the sf object, which is assigned the value UT_ecoregions; (6) mdcaty: assigned the value “level3_nam”; and (7) shapefile: assigned the value FALSE. Upon completion of the call to grts, the initial six sites for the survey design and a design summary are printed.

Create the design list:

Paneldsgn <- list(None=list(panel=c(Year1=10, Year2=10, Year3=10,
                                    Year4=10, Year5=10),
                            seltype="Unequal",
                            caty.n=c("Central Basin and Range"=10,
                                     "Colorado Plateaus"=10,
                                     "Mojave Basin and Range"=5,
                                     "Northern Basin and Range"=5,
                                     "Southern Rockies"=5,
                                     "Wasatch and Uinta Mountains"=10,
                                     "Wyoming Basin"=5),
                            over=5))

Select the sample:

Panelsites <- grts(design=Paneldsgn,
                   DesignID="UNEQUAL",
                   type.frame="area",
                   src.frame="sf.object",
                   sf.object=UT_ecoregions,
                   mdcaty="Level3_Nam",                                 
                   shapefile=FALSE)
#> 
#> Stratum: None
#> Warning in grts(design = Paneldsgn, DesignID = "UNEQUAL", type.frame = "area", : 
#> Oversample size is not proportional to category sample sizes for stratum
#> "None".
#> Current number of levels: 3 
#> Current number of levels: 5 
#> Current number of levels: 6 
#> Final number of levels: 6

Print the warning message:

warnings()

Print the initial six lines of the survey design:

head(Panelsites)
#>           coordinates     siteID   xcoord  ycoord
#> 1 (-1107027, 2072499) UNEQUAL-01 -1107027 2072499
#> 2 (-1233259, 1743431) UNEQUAL-02 -1233259 1743431
#> 3 (-1163898, 1752840) UNEQUAL-03 -1163898 1752840
#> 4 (-1570949, 1706658) UNEQUAL-04 -1570949 1706658
#> 5 (-1338758, 2182728) UNEQUAL-05 -1338758 2182728
#> 6 (-1339616, 1781210) UNEQUAL-06 -1339616 1781210
#>                        mdcaty        wgt stratum panel EvalStatus
#> 1               Wyoming Basin  582117660    None Year1    NotEval
#> 2           Colorado Plateaus 8579716309    None Year1    NotEval
#> 3           Colorado Plateaus 8579716309    None Year1    NotEval
#> 4      Mojave Basin and Range  386372151    None Year1    NotEval
#> 5     Central Basin and Range 8206454636    None Year1    NotEval
#> 6 Wasatch and Uinta Mountains 4353925113    None Year1    NotEval
#>   EvalReason Level3     Area_ha
#> 1                18 1.33312e+11
#> 2                20 1.26379e+11
#> 3                20 1.26379e+11
#> 4                14 1.29599e+11
#> 5                13 3.09949e+11
#> 6                19 4.47240e+10

Print the survey design summary:

summary(Panelsites)
#> 
#> 
#> Design Summary: Number of Sites Classified by mdcaty (Multidensity Category) 
#>  and panel
#> 
#>                              panel
#> mdcaty                        OverSamp Year1 Year2 Year3 Year4 Year5 Sum
#>   Central Basin and Range            0     2     2     3     2     1  10
#>   Colorado Plateaus                  1     3     3     1     3     2  13
#>   Mojave Basin and Range             2     1     1     1     0     0   5
#>   Northern Basin and Range           2     0     1     1     0     2   6
#>   Southern Rockies                   1     0     1     1     1     2   6
#>   Wasatch and Uinta Mountains        1     3     0     3     3     3  13
#>   Wyoming Basin                      0     1     2     0     1     0   4
#>   Sum                                7    10    10    10    10    10  57