Closed Robinlovelace closed 1 year ago
There are some cases in which line_segmentize() returns an incorrect number of features.
line_segmentize()
As illustrated below.
failing_line = structure(list(structure(c(324957.69921197, 324957.873557727, 324959.863123514, 324961.852683597, 324963.822867622, 324969.636546456, 324976.718443977, 324996.443964294, 673670.123131518, 673680.139281405, 673686.784106964, 673693.428933452, 673698.960855279, 673709.992098018, 673722.114520549, 673742.922904206), dim = c(8L, 2L), class = c("XY", "LINESTRING", "sfg"))), class = c("sfc_LINESTRING", "sfc"), precision = 0, bbox = structure(c(xmin = 324957.69921197, ymin = 673670.123131518, xmax = 324996.443964294, ymax = 673742.922904206 ), class = "bbox"), n_empty = 0L) sf::st_crs(failing_line) = "EPSG:27700" # Try with rsgeo: geo <- rsgeo::as_rsgeo(sf::st_geometry(failing_line)) # segmentize the line strings res <- rsgeo::line_segmentize(geo, 4) res <- sf::st_cast(sf::st_as_sfc(res), "LINESTRING") res #> Geometry set for 3 features #> Geometry type: LINESTRING #> Dimension: XY #> Bounding box: xmin: 324957.7 ymin: 673670.1 xmax: 324996.4 ymax: 673742.9 #> CRS: NA #> LINESTRING (324957.7 673670.1, 324957.9 673680.... #> LINESTRING (324961.1 673690.9, 324961.9 673693.... #> LINESTRING (324969.8 673710.2, 324976.7 673722.... length(res) # should be 4 #> [1] 3 sf::st_length(res) #> [1] 21.23587 21.23587 42.47173
Created on 2023-10-01 with reprex v2.0.2
There are some cases in which
line_segmentize()
returns an incorrect number of features.As illustrated below.
Created on 2023-10-01 with reprex v2.0.2