Skip to content

Commit

Permalink
add bbox sampling method
Browse files Browse the repository at this point in the history
  • Loading branch information
JosiahParry committed Dec 7, 2023
1 parent 2c2cf93 commit 4a63ecb
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 4a63ecb

Please sign in to comment.