Learn R Programming

riverdist (version 0.17.0)

pointshp2segvert: Convert a Point Shapefile to River Locations

Description

This function reads a point shapefile and determines the closest vertex in the river network to each point of XY data, returning a data frame with river locations, defined as segment numbers and vertex numbers, along with the data table read from the input shapefile.

Usage

pointshp2segvert(path = ".", layer, rivers)

Value

A data frame of river locations, with segment numbers in

$seg, vertex numbers in $vert, snapping distances in

$snapdist, snapped x- and y-coordinates in $snap_x and $snap_y, and the remaining columns corresponding to the data table in the input point shapefile.

Arguments

path

File path, default is the current working directory.

layer

Name of the shapefile, without the .shp extension.

rivers

The river network object to use.

Author

Matt Tyers

See Also

xy2segvert

Examples

Run this code
filepath <- system.file("extdata", package="riverdist")

fakefish_UTM5 <- pointshp2segvert(path=filepath, layer="fakefish_UTM5", rivers=Gulk)
head(fakefish_UTM5)

plot(x=Gulk)
points(fakefish_UTM5$x, fakefish_UTM5$y)
riverpoints(seg=fakefish_UTM5$seg, vert=fakefish_UTM5$vert, rivers=Gulk, pch=16, col=2)

Run the code above in your browser using DataLab