Learn R Programming

stplanr (version 0.1.4)

toptail_buff: Clip the beginning and ends SpatialLines to the edge of SpatialPolygon borders

Description

Takes lines and removes the start and end point, to a distance determined by the nearest polygon border.

Usage

toptail_buff(l, buff, ...)

Arguments

l
A SpatialLines object
buff
A SpatialPolygons object to act as the buffer
...
Arguments passed to rgeos::gBuffer()

Examples

Run this code
data("routes_fast")
data("zones")
r_toptail <- toptail_buff(routes_fast, zones)
sel <- row.names(routes_fast) %in% row.names(r_toptail)
rf_cross_poly <- routes_fast[sel,]
plot(zones)
plot(routes_fast, col = "blue", lwd = 4, add = TRUE)
# note adjacent lines removed
plot(rf_cross_poly, add = TRUE, lwd = 2)
plot(r_toptail, col = "red", add = TRUE)

Run the code above in your browser using DataLab