View source: R/cutLineDownstream.R
cutLineDownstream | R Documentation |
Cut off the down stream segment of a river segment at a point
cutLineDownstream(line, pt)
line |
a spatial line. |
pt |
a spatial point, previously snapped to |
A spatial lines object.
library(sp)
bng <- CRS("+init=epsg:27700")
cc <- cbind(c(0,0), c(0,1))
line <- SpatialLines(list(Lines(list(Line(cc)), ID = "A")), bng)
pt <- SpatialPoints(cbind(0, .5), bng)
down_line <- cutLineDownstream(line, pt)
plot(line)
points(cc)
points(pt, col = "green")
lines(down_line, col = "red")
y <- function(x) 0.1*x^2
cc <- cbind(-10:10, y(-10:10))
line <- SpatialLines(list(Lines(list(Line(cc)), ID = "A")), bng)
pt <- SpatialPoints(cbind(-8.020474, 6.493534), bng)
pt <- snapPointsToLines(pt, line)
down_line <- cutLineDownstream(line, pt)
plot(down_line, col = "red", lwd = 2, xlim = c(-10, -2), ylim = c(5, 10))
lines(line)
points(cc)
points(pt, col = "green")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.