Draws a BAS sample from a SpatialPolygons* object
bas.polygon(x, n)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.
Sample size. Number of locations to draw from the union of all
polygons contained in x.
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).
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.
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.
# 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