From 4a63ecb440ba02f0492ce3add56e4fa60fc82617 Mon Sep 17 00:00:00 2001 From: Josiah Parry Date: Thu, 7 Dec 2023 11:12:39 -0500 Subject: [PATCH] add bbox sampling method --- R/sample.R | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/R/sample.R b/R/sample.R index 9cd74d8c6..29b84df53 100644 --- a/R/sample.R +++ b/R/sample.R @@ -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) {