Learn R Programming

riverdist (version 0.17.0)

trimtopoints: Trim a River Network to a Set of X-Y Coordinates

Description

Removes line segments from a river network object that are not adjacent to a set of point data, given in X-Y coordinates.

Usage

trimtopoints(x, y, rivers, method = "snap", dist = NULL)

Value

A new river network object (see rivernetwork)

Arguments

x

Vector of x-coordinates of point data to buffer around

y

Vector of y-coordinates of point data to buffer around

rivers

The river network object to use

method

Three methods are available. If "snap" is specified (the default), only the closest segment to each point is retained. If "snaproute" is specified, segments are also retained that will maintain total connectivity in the resulting river network. If "buffer" is specified, all segments with endpoints or midpoints within dist units of the input locations are retained.

dist

Distance to use for buffering, if method="buffer". If this is not specified, the maximum spread in the x- and y- direction will be used.

Author

Matt Tyers

See Also

line2network

Examples

Run this code
data(Koyukuk2)
x <- c(139241.0, 139416.1, 124600.1, 122226.8)
y <- c(1917577, 1913864, 1898723, 1898792)

plot(x=Koyukuk2)
points(x, y, pch=15, col=4)
legend(par("usr")[1], par("usr")[4], legend="points to buffer around", pch=15, col=4, cex=.6)

Koyukuk2.buf1 <- trimtopoints(x, y, rivers=Koyukuk2, method="snap")
plot(x=Koyukuk2.buf1)
points(x, y, pch=15, col=4)

Koyukuk2.buf2 <- trimtopoints(x, y, rivers=Koyukuk2, method="snaproute")
plot(x=Koyukuk2.buf2)
points(x, y, pch=15, col=4)

Koyukuk2.buf3 <- trimtopoints(x, y, rivers=Koyukuk2, method="buffer", dist=1000)
plot(x=Koyukuk2.buf3)
points(x, y, pch=15, col=4)

Run the code above in your browser using DataLab