stplanr (version 0.3.1)

overline: Convert series of overlapping lines into a route network

Description

This function takes a series of Lines stored in a SpatialLinesDataFrame and converts these into a single route network.

Usage

overline(sl, attrib, fun = sum, na.zero = FALSE, buff_dist = 0)

Arguments

sl

A SpatialLinesDataFrame with overlapping elements

attrib

A character vector corresponding to the variables in sl$ on which the function(s) will operate.

fun

The function(s) used to aggregate the grouped values (default: sum). If length of fun is smaller than attrib then the functions are repeated for subsequent attributes.

na.zero

Sets whether aggregated values with a value of zero are removed.

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.

References

Rowlingson, B (2015). Overlaying lines and aggregating their values for overlapping segments. Reproducible question from http://gis.stackexchange.com. See http://gis.stackexchange.com/questions/139681/overlaying-lines-and-aggregating-their-values-for-overlapping-segments.

See Also

Other rnet: SpatialLinesNetwork, calc_catchment_sum, calc_catchment, calc_moving_catchment, calc_network_catchment, find_network_nodes, gsection, islines, lineLabels, overline2, plot,SpatialLinesNetwork,ANY-method, plot,sfNetwork,ANY-method, sln2points, sum_network_links, sum_network_routes

Examples

Run this code
# NOT RUN {
sl <- routes_fast[2:4, ]
rnet1 <- overline(sl = sl, attrib = "length")
rnet2 <- overline(sl = sl, attrib = "length", buff_dist = 1)
plot(rnet1, lwd = rnet1$length / mean(rnet1$length))
plot(rnet2, lwd = rnet2$length / mean(rnet2$length))
# }
# NOT RUN {
# sf methods
sl <- routes_fast_sf[2:4, ]
rnet_sf <- overline(sl = sl, attrib = "length", buff_dist = 10)
plot(rnet_sf, lwd = rnet_sf$length / mean(rnet_sf$length))
# }

Run the code above in your browser using DataCamp Workspace