prep_reach_dist {streamDepletr} | R Documentation |
Calculate the distance from a well to each reach within a stream network. This function splits a polyline stream network up into a series of evenly spaced points and calculates the distance from each of those points to a well.
Description
Calculate the distance from a well to each reach within a stream network. This function splits a polyline stream network up into a series of evenly spaced points and calculates the distance from each of those points to a well.
Usage
prep_reach_dist(
wel_lon,
wel_lat,
stream_sf,
reach_id,
stream_pt_spacing,
nseed = 1
)
Arguments
wel_lon |
longitude of well |
wel_lat |
latitude of well |
stream_sf |
simple feature collection of stream lines, i.e., loaded from a shapefile using |
reach_id |
string indicating name of column in |
stream_pt_spacing |
distance between points used for sampling each stream reach. The actual distance between points will be close to this (but not necessarily exact) due to sampling rounding error. The finer spacing you use, the more accurate your results will be but the function will run slower and use more memory. |
nseed |
seed for random number generator (this is used to convert stream polylines to points) |
Value
A data frame with four columns:
- reach
a grouping variable with the name of each stream reach
- dist
distance of a point on that stream reach to the well of interest
- lat
latitude of that point
- lon
longitude of that point
This data frame can be plugged directly into apportion_inverse, apportion_polygon (if latlon=T
),
or apportion_web
Examples
rdll <- prep_reach_dist(wel_lon = 295500, wel_lat = 4783200,
stream_sf = stream_lines, reach_id = "reach", stream_pt_spacing = 5)
head(rdll)