You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#' @details For most predicates, a spatial index is built on argument \code{x}; see \url{https://r-spatial.org/r/2017/06/22/spatial-index.html}.
122
121
#' Specifically, \code{st_intersects}, \code{st_disjoint}, \code{st_touches} \code{st_crosses}, \code{st_within}, \code{st_contains}, \code{st_contains_properly}, \code{st_overlaps}, \code{st_equals}, \code{st_covers} and \code{st_covered_by} all build spatial indexes for more efficient geometry calculations. \code{st_relate}, \code{st_equals_exact}, and do not; \code{st_is_within_distance} uses a spatial index for geographic coordinates when \code{sf_use_s2()} is true.
123
122
#'
124
-
#' If \code{y} is missing, `st_predicate(x, x)` is effectively called, and a square matrix is returned with diagonal elements `st_predicate(x[i], x[i])`.
123
+
#' If \code{y} is missing, `st_<predicate>(x, x)` is effectively called, and a square matrix is returned with diagonal elements `st_predicate(x[i], x[i])`.
125
124
#'
126
125
#' Sparse geometry binary predicate (\code{\link{sgbp}}) lists have the following attributes: \code{region.id} with the \code{row.names} of \code{x} (if any, else \code{1:n}), \code{ncol} with the number of features in \code{y}, and \code{predicate} with the name of the predicate used.
127
126
#'
128
127
#' @note For intersection on pairs of simple feature geometries, use
129
128
#' the function \code{\link{st_intersection}} instead of \code{st_intersects}.
129
+
#' @family geometric binary predicates for two spatial objects
st_within=function(x, y, sparse=TRUE, prepared=TRUE, ...)
194
194
st_geos_binop("within", x, y, sparse=sparse, prepared=prepared, ...)
195
195
196
-
#' @name geos_binary_pred
196
+
#' Identify if y is within x
197
+
#'
198
+
#' * `st_contains()` is true if
199
+
#' * `st_contains_properly(x, y)` is true if `x` intersects `y`'s interior, but not its edges or exterior; `x` contains `x`, but `x` does not properly contain `x`.
197
200
#' @param model character; polygon/polyline model; one of
198
201
#' "open", "semi-open" or "closed"; see Details.
199
202
#' @details for \code{model}, see https://github.com/r-spatial/s2/issues/32
203
+
#' @inheritParams st_intersects
200
204
#' @export
205
+
#' @family geometric binary predicates for two spatial objects
201
206
st_contains=function(x, y, sparse=TRUE, prepared=TRUE, ..., model="open")
202
207
st_geos_binop("contains", x, y, sparse=sparse, prepared=prepared, ..., model=model)
203
208
204
-
#' @name geos_binary_pred
209
+
#' @rdname st_contains
205
210
#' @export
206
-
#' @details `st_contains_properly(A,B)` is true if A intersects B's interior, but not its edges or exterior; A contains A, but A does not properly contain A.
207
-
#'
211
+
#' @details
208
212
#' See also \link{st_relate} and \url{https://en.wikipedia.org/wiki/DE-9IM} for a more detailed description of the underlying algorithms.
209
213
st_contains_properly=function(x, y, sparse=TRUE, prepared=TRUE, ...) {
st_overlaps=function(x, y, sparse=TRUE, prepared=TRUE, ...)
218
222
st_geos_binop("overlaps", x, y, sparse=sparse, prepared=prepared, ...)
219
223
220
-
#' @name geos_binary_pred
221
-
#' @param retain_unique logical; if `TRUE` (and `y` is missing) return only indexes of points larger than the current index; this can be used to select unique geometries, see examples. This argument can be used for all geometry predicates; see also \link{distinct.sf} to find records where geometries AND attributes are distinct.
224
+
225
+
#' Verify if geographies are equal
226
+
#'
227
+
#' * `st_equals()` validate if x and y are equal.
228
+
#' * `st_equals_exact()` returns true for two geometries of the same type and their vertices corresponding by index are equal up to a specified tolerance.
229
+
#'
230
+
#' @inheritParams st_intersects
231
+
#' @param retain_unique logical; if `TRUE` (and `y` is missing) return only
232
+
#' indexes of points larger than the current index; this can be used to select
233
+
#' unique geometries, see examples. This argument can be used for all geometry predicates;
234
+
#' see also \link{distinct.sf} to find records where geometries AND attributes are distinct.
222
235
#' @param remove_self logical; if `TRUE` (and `y` is missing) return only indexes of geometries different from the current index; this can be used to omit self-intersections; see examples. This argument can be used for all geometry predicates
223
236
#' @export
237
+
#' @family geometric binary predicates for two spatial objects
224
238
st_equals=function(x, y, sparse=TRUE, prepared=FALSE, ...,
225
239
retain_unique=FALSE, remove_self=FALSE) {
226
240
if (prepared)
@@ -241,10 +255,9 @@ st_covered_by = function(x, y = x, sparse = TRUE, prepared = TRUE, ..., model =
241
255
st_geos_binop("covered_by", x, y, sparse=sparse, prepared=prepared, ...)
242
256
243
257
244
-
#' @name geos_binary_pred
258
+
#' @rdname st_equals
245
259
#' @export
246
260
#' @param par numeric; parameter used for "equals_exact" (margin);
247
-
#' @details \code{st_equals_exact} returns true for two geometries of the same type and their vertices corresponding by index are equal up to a specified tolerance.
248
261
st_equals_exact=function(x, y, par, sparse=TRUE, prepared=FALSE, ...) {
249
262
if (prepared)
250
263
stop("prepared geometries not supported for st_equals_exact")
#' Methods for dealing with sparse geometry binary predicate lists
24
+
#' Sparse Geometry Binary Predicate Lists.
25
25
#'
26
+
#' @description
26
27
#' Methods for dealing with sparse geometry binary predicate lists
28
+
#' \code{sgbp} are sparse matrices, stored as a list with integer vectors holding
29
+
#' the ordered \code{TRUE} indices of each row. This means that for a dense,
30
+
#' \eqn{m \times n}{m x n} matrix \code{Q} and a list \code{L},
31
+
#' if \code{Q[i,j]} is \code{TRUE} then \eqn{j} is an element of \code{L[[i]]}.
32
+
#'
33
+
#' Reversed: when \eqn{k} is the value of \code{L[[i]][j]}, then \code{Q[i,k]} is \code{TRUE}.
27
34
#' @name sgbp
28
35
#' @export
29
36
#' @param x object of class \code{sgbp}
30
37
#' @param ... ignored
31
38
#' @param n integer; maximum number of items to print
32
39
#' @param max_nb integer; maximum number of neighbours to print for each item
33
-
#' @details \code{sgbp} are sparse matrices, stored as a list with integer vectors holding the ordered \code{TRUE} indices of each row. This means that for a dense, \eqn{m \times n}{m x n} matrix \code{Q} and a list \code{L}, if \code{Q[i,j]} is \code{TRUE} then \eqn{j} is an element of \code{L[[i]]}. Reversed: when \eqn{k} is the value of \code{L[[i]][j]}, then \code{Q[i,k]} is \code{TRUE}.
34
40
print.sgbp=function(x, ..., n=10, max_nb=10) {
35
41
n= min(length(x), n)
36
42
hd= paste0("Sparse geometry binary predicate list of length ", length(x), ", ",
0 commit comments