From 681b6b18ed88a219b124e896c4faad598c30eaec Mon Sep 17 00:00:00 2001 From: olivroy Date: Wed, 9 Oct 2024 12:02:38 -0400 Subject: [PATCH] fix docs --- R/geos_binary_pred.R | 64 +++++++++++++++++++++-------------------- man/geos_binary_pred.Rd | 3 ++ 2 files changed, 36 insertions(+), 31 deletions(-) diff --git a/R/geos_binary_pred.R b/R/geos_binary_pred.R index b56b4908e..92f1c9e0f 100644 --- a/R/geos_binary_pred.R +++ b/R/geos_binary_pred.R @@ -1,31 +1,33 @@ -#' Geometric binary predicates on pairs of simple feature geometry sets -#' -#' @description -#' -#' For most predicates, a spatial index is built on argument `x`; -#' see \url{https://r-spatial.org/r/2017/06/22/spatial-index.html}. -#' -#' If `prepared = TRUE`, `x` contains POINT geometries, and `y` contains polygons, -#' then the polygon geometries are prepared, rather than the points. -#' @name geos_binary_pred -#' @family geometric binary predicates for two spatial objects -#' @examples -#' 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)))) -#' (lst = st_intersects(pts, pol)) -#' (mat = st_intersects(pts, pol, sparse = FALSE)) -#' # which points fall inside a polygon? -#' apply(mat, 1, any) -#' lengths(lst) > 0 -#' # which points fall inside the first polygon? -#' st_intersects(pol, pts)[[1]] -#' # remove duplicate geometries: -#' p1 = st_point(0:1) -#' p2 = st_point(2:1) -#' p = st_sf(a = letters[1:8], geom = st_sfc(p1, p1, p2, p1, p1, p2, p2, p1)) -#' st_equals(p) -#' st_equals(p, remove_self = TRUE) -#' (u = st_equals(p, retain_unique = TRUE)) -#' # retain the records with unique geometries: -#' p[-unlist(u),] -NULL +#' Geometric binary predicates on pairs of simple feature geometry sets +#' +#' @description +#' +#' For most predicates, a spatial index is built on argument `x`; +#' see \url{https://r-spatial.org/r/2017/06/22/spatial-index.html}. +#' +#' If `prepared = TRUE`, `x` contains POINT geometries, and `y` contains polygons, +#' then the polygon geometries are prepared, rather than the points. +#' @name geos_binary_pred +#' @family geometric binary predicates for two spatial objects +#' @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 +#' @examples +#' 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)))) +#' (lst = st_intersects(pts, pol)) +#' (mat = st_intersects(pts, pol, sparse = FALSE)) +#' # which points fall inside a polygon? +#' apply(mat, 1, any) +#' lengths(lst) > 0 +#' # which points fall inside the first polygon? +#' st_intersects(pol, pts)[[1]] +#' # remove duplicate geometries: +#' p1 = st_point(0:1) +#' p2 = st_point(2:1) +#' p = st_sf(a = letters[1:8], geom = st_sfc(p1, p1, p2, p1, p1, p2, p2, p1)) +#' st_equals(p) +#' st_equals(p, remove_self = TRUE) +#' (u = st_equals(p, retain_unique = TRUE)) +#' # retain the records with unique geometries: +#' p[-unlist(u),] +NULL diff --git a/man/geos_binary_pred.Rd b/man/geos_binary_pred.Rd index 8ca273210..517f8a549 100644 --- a/man/geos_binary_pred.Rd +++ b/man/geos_binary_pred.Rd @@ -71,6 +71,9 @@ boolean operation.} \code{"open"}, \code{"semi-open"} or \code{"closed"}; see Details.} \item{dist}{distance threshold; geometry indexes with distances smaller or equal to this value are returned; numeric value or units value having distance units.} + +\item{remove_self}{logical; if \code{TRUE} (and \code{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} } \description{ For most predicates, a spatial index is built on argument \code{x};