Skip to content

Commit

Permalink
Merge pull request #2283 from JosiahParry/sample-bbox
Browse files Browse the repository at this point in the history
Add bbox method to st_sample()
  • Loading branch information
edzer authored Dec 10, 2023
2 parents b3e9dbb + 4a63ecb commit b070c93
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions R/sample.R
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,19 @@ st_sample.sfg = function(x, size, ...) {
st_sample(st_geometry(x), size, ...)
}

#' @export
#' @name st_sample
#' @examples
#' bbox = st_bbox(
#' c(xmin = 16.1, xmax = 16.6, ymax = 48.6, ymin = 47.9),
#' crs = st_crs(4326)
#' )
#'
#' st_sample(bbox, 5)
st_sample.bbox = function(x, size, ...) {
st_sample(st_as_sfc(x), size, ...)
}

st_poly_sample = function(x, size, ..., type = "random",
offset = st_sample(st_as_sfc(st_bbox(x)), 1)[[1]],
by_polygon = FALSE) {
Expand Down

0 comments on commit b070c93

Please sign in to comment.