I have these 3 lines:
line1 <- matrix(c(-1.81209, -1.80470, -1.80616, 55.68024, 55.67947,
55.67544), ncol=2)
line2 <- matrix(c(-1.80468, -1.80330, -1.79690, 55.68322, 55.68017,
55.67800), ncol=2)
line3 <- matrix(c(-1.79798, -1.80069, -1.78929, 55.68364, 55.68138,
55.67966), ncol=2)
line1L <- Line(line1)
line2L <- Line(line2)
line3L <- Line(line3)
my.lines <- Lines(list(line1L, line2L, line3L), ID="my.lines")
myLines <- SpatialLines(list(my.lines))
proj4string(myLines) <- CRS("+proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0")
myLinesSpatial <- spTransform(myLines, CRS("+init=epsg:27700 +datum=WGS84"))
plot(myLinesSpatial)
I need to discard any part of any line, that falls within 100m of any other
line. This will result in segments of each of the three lines being removed.
How can I do this?
Best Answer
This can be done with the
rgeos
package, e.g. withgBuffer
andgDifference
: