From b2b09db34bb22a39adf7403005f72f70b6a4c3b7 Mon Sep 17 00:00:00 2001 From: Luuk van der Meer Date: Sun, 17 Nov 2024 19:11:17 +0100 Subject: [PATCH] refactor: Tidy :construction: --- R/create.R | 6 +++--- R/ids.R | 4 ++-- R/nb.R | 4 ++-- R/weights.R | 2 +- man/as_sfnetwork.Rd | 4 ++-- man/create_from_spatial_points.Rd | 2 +- man/evaluate_edge_query.Rd | 2 +- man/evaluate_node_query.Rd | 2 +- man/evaluate_weight_spec.Rd | 2 +- man/nb.Rd | 4 ++-- man/st_network_iso.Rd | 18 +++++++++++------- 11 files changed, 27 insertions(+), 23 deletions(-) diff --git a/R/create.R b/R/create.R index f8f6cdb9..dbacb715 100644 --- a/R/create.R +++ b/R/create.R @@ -208,7 +208,7 @@ as_sfnetwork = function(x, ...) { #' an \code{\link[sf]{sf}} object through \code{\link[sf]{st_as_sf}}. Arguments #' to \code{\link[sf]{st_as_sf}} can be provided as additional arguments and #' will be forwarded to \code{\link[sf]{st_as_sf}} through the -#' code{\link{sfnetwork}} construction function. +#' \code{\link{sfnetwork}} construction function. #' #' @importFrom tidygraph as_tbl_graph #' @export @@ -380,7 +380,7 @@ as_sfnetwork.sfNetwork = function(x, ...) { #' \code{\link[sf]{sf}} object through \code{\link[sf]{st_as_sf}}. Arguments #' to \code{\link[sf]{st_as_sf}} can be provided as additional arguments and #' will be forwarded to \code{\link[sf]{st_as_sf}} through the -#' code{\link{sfnetwork}} construction function. The directness of the original +#' \code{\link{sfnetwork}} construction function. The directness of the original #' graph is preserved unless specified otherwise through the \code{directed} #' argument. #' @@ -591,7 +591,7 @@ create_from_spatial_lines = function(x, directed = TRUE, compute_length = FALSE, #' whenever possible. #' #' The provided adjacency matrix may also be sparse. This can be an object of -#' one of the sparse matrix classes from the \code{\pkg{Matrix}} package, or a +#' one of the sparse matrix classes from the \pkg{Matrix} package, or a #' list-formatted sparse matrix. This is a list with one element per node, #' holding the integer indices of the nodes it is adjacent to. An example are #' \code{\link[sf]{sgbp}} objects. If the values are not integers, they are diff --git a/R/ids.R b/R/ids.R index ee9f5560..5f01defb 100644 --- a/R/ids.R +++ b/R/ids.R @@ -46,7 +46,7 @@ edge_ids = function(x, focused = TRUE) { #' @param data An object of class \code{\link{sfnetwork}}. #' #' @param query The query that defines for which nodes to extract indices, -#' defused into a \code{\link[dplyr:topic-quosure]{quosure}}. See Details for +#' defused into a \code{\link[rlang:topic-quosure]{quosure}}. See Details for #' the different ways in which node queries can be formulated. #' #' @details There are multiple ways in which node indices can be queried in @@ -121,7 +121,7 @@ evaluate_node_query = function(data, query) { #' @param data An object of class \code{\link{sfnetwork}}. #' #' @param query The query that defines for which edges to extract indices, -#' defused into a \code{\link[dplyr:topic-quosure]{quosure}}. See Details for +#' defused into a \code{\link[rlang:topic-quosure]{quosure}}. See Details for #' the different ways in which edge queries can be formulated. #' #' @details There are multiple ways in which edge indices can be queried in diff --git a/R/nb.R b/R/nb.R index 60d6ca80..4a9f27ef 100644 --- a/R/nb.R +++ b/R/nb.R @@ -2,8 +2,8 @@ #' #' Neighbor lists are sparse adjacency matrices in list format that specify for #' each node to which other nodes it is adjacent. They occur for example in the -#' \code{\pkg{sf}} package as \code{\link[sf]{sgbp}} objects, and are also -#' frequently used in the \code{\pkg{spdep}} package. +#' \pkg{sf} package as \code{\link[sf]{sgbp}} objects, and are also +#' frequently used in the \pkg{spdep} package. #' #' @param x For the conversion to sfnetwork: a neighbor list, which is a list # with one element per node that holds the integer indices of the nodes it is diff --git a/R/weights.R b/R/weights.R index d60a74f7..39159416 100644 --- a/R/weights.R +++ b/R/weights.R @@ -6,7 +6,7 @@ #' @param data An object of class \code{\link{sfnetwork}}. #' #' @param spec The specification that defines how to compute or extract edge -#' weights defused into a \code{\link[dplyr:topic-quosure]{quosure}}. See +#' weights defused into a \code{\link[rlang:topic-quosure]{quosure}}. See #' Details for the different ways in which edge weights can be specified. #' #' @details There are multiple ways in which edge weights can be specified in diff --git a/man/as_sfnetwork.Rd b/man/as_sfnetwork.Rd index 817c512c..3da079f1 100644 --- a/man/as_sfnetwork.Rd +++ b/man/as_sfnetwork.Rd @@ -50,7 +50,7 @@ into a \code{\link[tidygraph]{tbl_graph}} using an \code{\link[sf]{sf}} object through \code{\link[sf]{st_as_sf}}. Arguments to \code{\link[sf]{st_as_sf}} can be provided as additional arguments and will be forwarded to \code{\link[sf]{st_as_sf}} through the -code{\link{sfnetwork}} construction function. +\code{\link{sfnetwork}} construction function. \item \code{as_sfnetwork(sf)}: Convert spatial features of class \code{\link[sf]{sf}} directly into a \code{\link{sfnetwork}}. @@ -105,7 +105,7 @@ This will work if at least the nodes can be converted to an \code{\link[sf]{sf}} object through \code{\link[sf]{st_as_sf}}. Arguments to \code{\link[sf]{st_as_sf}} can be provided as additional arguments and will be forwarded to \code{\link[sf]{st_as_sf}} through the -code{\link{sfnetwork}} construction function. The directness of the original +\code{\link{sfnetwork}} construction function. The directness of the original graph is preserved unless specified otherwise through the \code{directed} argument. diff --git a/man/create_from_spatial_points.Rd b/man/create_from_spatial_points.Rd index 0d15b40e..d5967ab7 100644 --- a/man/create_from_spatial_points.Rd +++ b/man/create_from_spatial_points.Rd @@ -63,7 +63,7 @@ are first converted into logical matrices using \code{\link{as.logical}}, whenever possible. The provided adjacency matrix may also be sparse. This can be an object of -one of the sparse matrix classes from the \code{\pkg{Matrix}} package, or a +one of the sparse matrix classes from the \pkg{Matrix} package, or a list-formatted sparse matrix. This is a list with one element per node, holding the integer indices of the nodes it is adjacent to. An example are \code{\link[sf]{sgbp}} objects. If the values are not integers, they are diff --git a/man/evaluate_edge_query.Rd b/man/evaluate_edge_query.Rd index 21044b6d..ee60ca02 100644 --- a/man/evaluate_edge_query.Rd +++ b/man/evaluate_edge_query.Rd @@ -10,7 +10,7 @@ evaluate_edge_query(data, query) \item{data}{An object of class \code{\link{sfnetwork}}.} \item{query}{The query that defines for which edges to extract indices, -defused into a \code{\link[dplyr:topic-quosure]{quosure}}. See Details for +defused into a \code{\link[rlang:topic-quosure]{quosure}}. See Details for the different ways in which edge queries can be formulated.} } \value{ diff --git a/man/evaluate_node_query.Rd b/man/evaluate_node_query.Rd index 0a4e7416..24d350c6 100644 --- a/man/evaluate_node_query.Rd +++ b/man/evaluate_node_query.Rd @@ -10,7 +10,7 @@ evaluate_node_query(data, query) \item{data}{An object of class \code{\link{sfnetwork}}.} \item{query}{The query that defines for which nodes to extract indices, -defused into a \code{\link[dplyr:topic-quosure]{quosure}}. See Details for +defused into a \code{\link[rlang:topic-quosure]{quosure}}. See Details for the different ways in which node queries can be formulated.} } \value{ diff --git a/man/evaluate_weight_spec.Rd b/man/evaluate_weight_spec.Rd index 8b7f83ec..9e83051a 100644 --- a/man/evaluate_weight_spec.Rd +++ b/man/evaluate_weight_spec.Rd @@ -10,7 +10,7 @@ evaluate_weight_spec(data, spec) \item{data}{An object of class \code{\link{sfnetwork}}.} \item{spec}{The specification that defines how to compute or extract edge -weights defused into a \code{\link[dplyr:topic-quosure]{quosure}}. See +weights defused into a \code{\link[rlang:topic-quosure]{quosure}}. See Details for the different ways in which edge weights can be specified.} } \value{ diff --git a/man/nb.Rd b/man/nb.Rd index 2b43b352..8f5dff17 100644 --- a/man/nb.Rd +++ b/man/nb.Rd @@ -59,6 +59,6 @@ the nodes it is adjacent to. \description{ Neighbor lists are sparse adjacency matrices in list format that specify for each node to which other nodes it is adjacent. They occur for example in the -\code{\pkg{sf}} package as \code{\link[sf]{sgbp}} objects, and are also -frequently used in the \code{\pkg{spdep}} package. +\pkg{sf} package as \code{\link[sf]{sgbp}} objects, and are also +frequently used in the \pkg{spdep} package. } diff --git a/man/st_network_iso.Rd b/man/st_network_iso.Rd index fc686a8f..3cb7dc09 100644 --- a/man/st_network_iso.Rd +++ b/man/st_network_iso.Rd @@ -74,17 +74,21 @@ library(sf, quietly = TRUE) oldpar = par(no.readonly = TRUE) par(mar = c(1,1,1,1)) -center = st_centroid(st_combine(st_geometry(roxel))) +# Note that this function requires GEOS >= 3.11! +if (compareVersion(sf_extSoftVersion()[["GEOS"]], "3.11.0") > -1) { -net = as_sfnetwork(roxel, directed = FALSE) + center = st_centroid(st_combine(st_geometry(roxel))) -iso = net |> - st_network_iso(node_is_nearest(center), c(1000, 500, 250), ratio = 0.3) + net = as_sfnetwork(roxel, directed = FALSE) -colors = c("#fee6ce90", "#fdae6b90", "#e6550d90") + iso = net |> + st_network_iso(node_is_nearest(center), c(1000, 500, 250), ratio = 0.3) -plot(net) -plot(st_geometry(iso), col = colors, add = TRUE) + colors = c("#fee6ce90", "#fdae6b90", "#e6550d90") + + plot(net) + plot(st_geometry(iso), col = colors, add = TRUE) +} par(oldpar)