cutLineDownstream: Cut off the down stream segment of a river segment at a point

View source: R/cutLineDownstream.R

cutLineDownstreamR Documentation

Cut off the down stream segment of a river segment at a point

Description

Cut off the down stream segment of a river segment at a point

Usage

cutLineDownstream(line, pt)

Arguments

line

a spatial line.

pt

a spatial point, previously snapped to line.

Value

A spatial lines object.

Examples

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")

Faskally/fflgis documentation built on Sept. 21, 2023, 1:15 p.m.