Skip to content

Commit 9e9b44f

Browse files
committed
docs #2308
1 parent 30bab8a commit 9e9b44f

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

R/sample.R

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ st_sample = function(x, size, ...) UseMethod("st_sample")
4040
#'
4141
#' Sampling methods from package \code{spatstat} are interfaced (see examples), and need their own parameters to be set.
4242
#' For instance, to use \code{spatstat.random::rThomas()}, set \code{type = "Thomas"}.
43+
#'
44+
#' For sampling polygons one can specify `oriented=TRUE` to make sure that polygons larger than half the globe are not reverted, e.g. when specifying a polygon from a bounding box of a global dataset. The `st_sample` method for `bbox` does this by default.
4345
#' @examples
4446
#' nc = st_read(system.file("shape/nc.shp", package="sf"))
4547
#' p1 = st_sample(nc[1:3, ], 6)
@@ -201,14 +203,9 @@ st_poly_sample = function(x, size, ..., type = "random",
201203
h1 = sin(bb["ymax"] * toRad)
202204
h2 = sin(bb["ymin"] * toRad)
203205
a0 = 2 * pi * R^2. * (h1 - h2) * (bb["xmax"] - bb["xmin"]) / 360.
204-
# a1 = as.numeric(sum(st_area(x)))
205206
a1 = sum(s2::s2_area(st_as_s2(x, oriented = oriented)))
206207
if (!is.finite(a1))
207208
stop("One or more geometries have a non-finite area")
208-
#if (a1 < 1) { # global polygon FIXME:
209-
# a1 = a0
210-
# global = TRUE
211-
#}
212209
global = (a1 / a0) > .9999
213210
size = round(size * a0 / a1)
214211
} else {

man/st_sample.Rd

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)