Learn R Programming

SDraw (version 2.1.13)

bas.polygon: Draws a Balanced Acceptance Sample (BAS) from an area resource (polygons).

Description

Draws a BAS sample from a SpatialPolygons* object

Usage

bas.polygon(x, n)

Arguments

x

A SpatialPolygons or SpatialPolygonsDataFrame object. This object must contain at least 1 polygon. If it contains more than 1 polygon, the BAS sample is drawn from the union of all.

n

Sample size. Number of locations to draw from the union of all polygons contained in x.

Value

A SDrawSample object, which is a SpatialPointsDataFrame object containing points in the BAS sample, in BAS order. Attributes of the sample points are:

  • sampleID: A unique identifier for every sample point. This encodes the BAS order. If BAS order is lost, return[ order( return$sampleID ),] will resort the returned object (i.e., return) into BAS order.

  • 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., "BAS").

  • random.start: The random seed of the random-start Halton sequence that produced the sample. This is a vector of length 2 whose elements are random integers between 0 and maxU. This routine ensures that the point associated with this index falls inside a polygon of x. i.e., that halton(1,2,random.start) scaled by a square bounding box (see attribute bas.bbox below) lies inside a polygon of x.

    Note that halton(1,2,random.start+i), for i > 0, is not guaranteed to fall inside a polygon of x when scaled by bas.bbox. The sample consists of the point associated with random.start and the next n-1 Halton points in sequence that fall inside a polygon of x.

  • bas.bbox: The square bounding box surrounding x used to scale Halton points. A scaled Halton sequence of n points is bas.bbox[,"min"] + t(halton(n,2,random.start)) * rep( max(diff(t(bas.bbox))), 2).

Details

A BAS sample is drawn from the union of all polygons in x by enclosing all polygons in a bounding square and selecting a randomized Halton sequence of points from the bounding square. Points falling outside all polygons are discarded until exactly n locations are selected inside the polygons.

The sampling frame for routine is infinite and contains all (infinitesimally small) points in the union of polygons in x.

References

Robertson, B.L., J. A. Brown, T. L. McDonald, and P. Jaksons (2013) "BAS: Balanced Acceptance Sampling of Natural Resources", Biometrics, v69, p. 776-784.

See Also

bas.line, bas.point, sdraw

Examples

Run this code
# NOT RUN {
#   Draw sample
WA_sample <- bas.polygon(WA, 100)  

#   Plot
plot( WA )

# Plot first 100 sample locations
points( WA_sample[ WA_sample$siteID <= 100, ], pch=16 ) 

# Plot second 100 locations 
points( WA_sample[ WA_sample$siteID >  100, ], pch=1 )  


# }

Run the code above in your browser using DataLab