stplanr (version 0.9.0)

gsection: Function to split overlapping SpatialLines into segments

Description

Divides SpatialLinesDataFrame objects into separate Lines. Each new Lines object is the aggregate of a single number of aggregated lines.

Usage

gsection(sl, buff_dist = 0)

Arguments

sl

SpatialLinesDataFrame with overlapping Lines to split by number of overlapping features.

buff_dist

A number specifying the distance in meters of the buffer to be used to crop lines before running the operation. If the distance is zero (the default) touching but non-overlapping lines may be aggregated.

See Also

Other rnet: SpatialLinesNetwork, calc_catchment_sum(), calc_catchment(), calc_moving_catchment(), calc_network_catchment(), find_network_nodes(), islines(), lineLabels(), overline_spatial(), overline(), plot,SpatialLinesNetwork,ANY-method, plot,sfNetwork,ANY-method, rnet_breakup_vertices(), rnet_group(), sln2points(), sum_network_links(), sum_network_routes()

Examples

Run this code
# NOT RUN {
lib_versions <- sf::sf_extSoftVersion()
lib_versions
# fails on some systems (with early versions of PROJ)
if (lib_versions[3] >= "6.3.1") {
  sl <- routes_fast_sf[2:4, ]
  rsec <- gsection(sl)
  length(rsec) # sections
  plot(rsec, col = seq(length(rsec)))
  rsec <- gsection(sl, buff_dist = 50)
  length(rsec) # 4 features: issue
  plot(rsec, col = seq(length(rsec)))
  # dont test due to issues with sp classes on some set-ups
  # sl <- routes_fast[2:4, ]
  # rsec <- gsection(sl)
  # rsec_buff <- gsection(sl, buff_dist = 1)
  # plot(sl[1], lwd = 9, col = 1:nrow(sl))
  # plot(rsec, col = 5 + (1:length(rsec)), add = TRUE, lwd = 3)
  # plot(rsec_buff, col = 5 + (1:length(rsec_buff)), add = TRUE, lwd = 3)
}
# }

Run the code above in your browser using DataLab