Skip to content

Commit b070c93

Browse files
authored
Merge pull request #2283 from JosiahParry/sample-bbox
Add bbox method to st_sample()
2 parents b3e9dbb + 4a63ecb commit b070c93

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

R/sample.R

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,19 @@ st_sample.sfg = function(x, size, ...) {
139139
st_sample(st_geometry(x), size, ...)
140140
}
141141

142+
#' @export
143+
#' @name st_sample
144+
#' @examples
145+
#' bbox = st_bbox(
146+
#' c(xmin = 16.1, xmax = 16.6, ymax = 48.6, ymin = 47.9),
147+
#' crs = st_crs(4326)
148+
#' )
149+
#'
150+
#' st_sample(bbox, 5)
151+
st_sample.bbox = function(x, size, ...) {
152+
st_sample(st_as_sfc(x), size, ...)
153+
}
154+
142155
st_poly_sample = function(x, size, ..., type = "random",
143156
offset = st_sample(st_as_sfc(st_bbox(x)), 1)[[1]],
144157
by_polygon = FALSE) {

0 commit comments

Comments
 (0)