View source: R/geometry_operation.R
st_any_pred | R Documentation |
Unlike functions in sf
like st_intersects
, this function simply
returns a logical vector indicating whether each geometry in x
intersects (or returns TRUE
from other predicates) anything in
y
, preferably when y
only contains a small number of geometries
or is one single MULTI geometry. This is useful when cropping or subsetting
an SFE object with a geometry, such as tissue boundary or histological region
polygons or a bounding box.
st_any_pred(x, y, pred, yx = FALSE, sparse = FALSE, ...)
st_any_intersects(x, y, yx = FALSE, sparse = FALSE)
st_n_pred(x, y, pred, ...)
st_n_intersects(x, y)
x |
An object of class |
y |
Another object of class |
pred |
A geometric binary predicate function, such as
|
yx |
Whether to do |
sparse |
If |
... |
Arguments passed to |
For st_any_*
, a logical vector indicating whether each
geometry in x
intersects (or other predicates such as is covered by)
anything in y
or a numeric vector of indices of TRUE
when
sparse = TRUE
. Simplified from the sgbp
results which
indicate which item in y
each item in x
intersects, which
might not always be relevant. For st_n_*
, an integer vector
indicating the number of geometries in y returns TRUE for each geometry in
x.
library(sf)
pts <- st_sfc(
st_point(c(.5, .5)), st_point(c(1.5, 1.5)),
st_point(c(2.5, 2.5))
)
pol <- st_polygon(list(rbind(c(0, 0), c(2, 0), c(2, 2), c(0, 2), c(0, 0))))
st_any_pred(pts, pol, pred = st_disjoint)
st_any_intersects(pts, pol)
st_n_pred(pts, pol, pred = st_disjoint)
st_n_intersects(pts, pol)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.