From b56266f45183069a58cd7a89a2f8fbb47316029a Mon Sep 17 00:00:00 2001 From: Andrea Gilardi Date: Wed, 24 Jan 2024 22:32:57 +0100 Subject: [PATCH 1/2] update st_graticule docs --- man/st_graticule.Rd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/man/st_graticule.Rd b/man/st_graticule.Rd index 4119b2917..8c906f943 100644 --- a/man/st_graticule.Rd +++ b/man/st_graticule.Rd @@ -66,7 +66,7 @@ bbox = st_linestring(rbind(c( bb[1],bb[2]),c( bb[3],bb[2]), c( bb[3],bb[4]),c( bb[1],bb[4]),c( bb[1],bb[2]))) g = st_graticule(usa) -plot(usa, xlim = 1.2 * c(-2450853.4, 2186391.9)) +plot(usa, xlim = 1.2 * c(-2450853.4, 2186391.9), reset = FALSE) plot(g[1], add = TRUE, col = 'grey') plot(bbox, add = TRUE) points(g$x_start, g$y_start, col = 'red') From 04c8c315919beb3766d33472963ead5e6985988a Mon Sep 17 00:00:00 2001 From: Andrea Gilardi Date: Thu, 25 Jan 2024 09:40:00 +0100 Subject: [PATCH 2/2] document [.sfc --- R/sfc.R | 8 ++++++++ man/sfc.Rd | 14 ++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/R/sfc.R b/R/sfc.R index bb2ba125f..db8199690 100644 --- a/R/sfc.R +++ b/R/sfc.R @@ -36,6 +36,7 @@ format.sfc = function(x, ..., width = 30) { #' pt1 = st_point(c(0,1)) #' pt2 = st_point(c(1,1)) #' (sfc = st_sfc(pt1, pt2)) +#' sfc[sfc[1], op = st_is_within_distance, dist = 0.5] #' d = st_sf(data.frame(a=1:2, geom=sfc)) #' @export st_sfc = function(..., crs = NA_crs_, precision = 0.0, check_ring_dir = FALSE, dim, @@ -139,6 +140,13 @@ st_sfc = function(..., crs = NA_crs_, precision = 0.0, check_ring_dir = FALSE, d lst } +#' @name sfc +#' @param x object of class \code{sfc} +#' @param i record selection. Might also be an \code{sfc}/\code{sf} object to work with the \code{op} argument +#' @param j ignored +#' @param op function, geometrical binary predicate function to apply when +#' \code{i} is a \code{sf}/\code{sfc} object. Additional arguments can be +#' specified using \code{...}, see examples. #' @export "[.sfc" = function(x, i, j, ..., op = st_intersects) { if (!missing(i) && (inherits(i, "sf") || inherits(i, "sfc") || inherits(i, "sfg"))) diff --git a/man/sfc.Rd b/man/sfc.Rd index 3a289b9d4..a4361e1c3 100644 --- a/man/sfc.Rd +++ b/man/sfc.Rd @@ -10,6 +10,7 @@ \alias{sfc_MULTILINESTRING} \alias{sfc_MULTIPOLYGON} \alias{sfc_GEOMETRYCOLLECTION} +\alias{[.sfc} \title{Create simple feature geometry list column} \usage{ st_sfc( @@ -20,6 +21,8 @@ st_sfc( dim, recompute_bbox = FALSE ) + +\method{[}{sfc}(x, i, j, ..., op = st_intersects) } \arguments{ \item{...}{zero or more simple feature geometries (objects of class \code{sfg}), or a single list of such objects; \code{NULL} values will get replaced by empty geometries.} @@ -33,6 +36,16 @@ st_sfc( \item{dim}{character; if this function is called without valid geometries, this argument may carry the right dimension to set empty geometries} \item{recompute_bbox}{logical; use \code{TRUE} to force recomputation of the bounding box} + +\item{x}{object of class \code{sfc}} + +\item{i}{record selection. Might also be an \code{sfc}/\code{sf} object to work with the \code{op} argument} + +\item{j}{ignored} + +\item{op}{function, geometrical binary predicate function to apply when +\code{i} is a \code{sf}/\code{sfc} object. Additional arguments can be +specified using \code{...}, see examples.} } \value{ an object of class \code{sfc}, which is a classed list-column with simple feature geometries. @@ -51,5 +64,6 @@ superclass \code{GEOMETRY}. pt1 = st_point(c(0,1)) pt2 = st_point(c(1,1)) (sfc = st_sfc(pt1, pt2)) +sfc[sfc[1], op = st_is_within_distance, dist = 0.5] d = st_sf(data.frame(a=1:2, geom=sfc)) }