diff --git a/R/decompose-linestring.R b/R/decompose-linestring.R index c5c85fe..3b6881c 100644 --- a/R/decompose-linestring.R +++ b/R/decompose-linestring.R @@ -1,8 +1,8 @@ -#' Decompose a linestring into a list of segments +#' Decompose a linestring into a list of line segments #' -#' This function decomposes a linestring into a list of segments, where each -#' segment is a linestring connecting two consecutive points of the input -#' linestring. +#' This function decomposes a linestring into a list of line segments, +#' where each segment is a linestring connecting two consecutive points +#' of the input linestring. #' #' @param linestring A linestring object. #' @return A list of linestring objects, each representing a segment of the @@ -12,7 +12,7 @@ #' # Create a linestring object #' linestring <- create_linestring(0, 0, 1, 1, 2, 1, 4, 0) #' -#' # Decompose the linestring into segments +#' # Decompose the linestring into line segments #' decompose_linestring(linestring) decompose_linestring <- function(linestring) { # Extract the coordinates of the linestring @@ -23,7 +23,7 @@ decompose_linestring <- function(linestring) { from <- coordinates[seq_len(num_points - 1), c("X", "Y")] to <- coordinates[seq_len(num_points - 1) + 1, c("X", "Y")] - # Create a list of segments + # Create a list of line segments segments <- apply(cbind(from, to), 1, create_linestring, simplify = FALSE) segments <- st_sfc(segments, crs = st_crs(linestring)) diff --git a/R/filter-points-within-tolerance.R b/R/filter-points-within-tolerance.R index ff8b68a..bf58ec4 100644 --- a/R/filter-points-within-tolerance.R +++ b/R/filter-points-within-tolerance.R @@ -5,9 +5,9 @@ #' #' @param points A `sfc` object containing points to filter. #' @param linestring A linestring object. -#' @param tolerance The maximum distance allowed between points and -#' the linestring. Points within this distance from the linestring -#' are kept in the result. +#' @param tolerance A numeric value representing the maximum allowable +#' distance between points and the linestring. Points within this +#' distance from the linestring will be included in the filtered set. #' @return A `sfc` object containing the filtered points. #' @export #' @examples @@ -15,16 +15,15 @@ #' #' # Create a points #' points <- st_sfc( -#' st_point(c(0.000, 0.000)), -#' st_point(c(1.000, 0.100)), -#' st_point(c(2.000, 0.010)), -#' st_point(c(4.000, 0.001)), -#' st_point(c(5.001, 0.000)), -#' st_point(c(6.000, 0.000)) +#' st_point(c(0.000, 1.000)), +#' st_point(c(0.500, 0.600)), +#' st_point(c(1.000, 0.010)), +#' st_point(c(1.500, 0.501)), +#' st_point(c(2.000, 0.990)) #' ) #' -#' # Create a linestring (reference geometry) -#' linestring <- create_linestring(0, 0, 5, 0) +#' # Create a linestring +#' linestring <- create_linestring(0, 1, 1, 0, 2, 1) #' #' # Plot the points #' plot(linestring, col = "gray") diff --git a/man/decompose_linestring.Rd b/man/decompose_linestring.Rd index aa36371..a28e024 100644 --- a/man/decompose_linestring.Rd +++ b/man/decompose_linestring.Rd @@ -2,7 +2,7 @@ % Please edit documentation in R/decompose-linestring.R \name{decompose_linestring} \alias{decompose_linestring} -\title{Decompose a linestring into a list of segments} +\title{Decompose a linestring into a list of line segments} \usage{ decompose_linestring(linestring) } @@ -14,14 +14,14 @@ A list of linestring objects, each representing a segment of the input linestring. } \description{ -This function decomposes a linestring into a list of segments, where each -segment is a linestring connecting two consecutive points of the input -linestring. +This function decomposes a linestring into a list of line segments, +where each segment is a linestring connecting two consecutive points +of the input linestring. } \examples{ # Create a linestring object linestring <- create_linestring(0, 0, 1, 1, 2, 1, 4, 0) -# Decompose the linestring into segments +# Decompose the linestring into line segments decompose_linestring(linestring) } diff --git a/man/filter_points_within_tolerance.Rd b/man/filter_points_within_tolerance.Rd index 51a7c6c..f709677 100644 --- a/man/filter_points_within_tolerance.Rd +++ b/man/filter_points_within_tolerance.Rd @@ -11,9 +11,9 @@ filter_points_within_tolerance(points, linestring, tolerance = 0.01) \item{linestring}{A linestring object.} -\item{tolerance}{The maximum distance allowed between points and -the linestring. Points within this distance from the linestring -are kept in the result.} +\item{tolerance}{A numeric value representing the maximum allowable +distance between points and the linestring. Points within this +distance from the linestring will be included in the filtered set.} } \value{ A \code{sfc} object containing the filtered points. @@ -27,16 +27,15 @@ library(sf) # Create a points points <- st_sfc( - st_point(c(0.000, 0.000)), - st_point(c(1.000, 0.100)), - st_point(c(2.000, 0.010)), - st_point(c(4.000, 0.001)), - st_point(c(5.001, 0.000)), - st_point(c(6.000, 0.000)) + st_point(c(0.000, 1.000)), + st_point(c(0.500, 0.600)), + st_point(c(1.000, 0.010)), + st_point(c(1.500, 0.501)), + st_point(c(2.000, 0.990)) ) -# Create a linestring (reference geometry) -linestring <- create_linestring(0, 0, 5, 0) +# Create a linestring +linestring <- create_linestring(0, 1, 1, 0, 2, 1) # Plot the points plot(linestring, col = "gray")