calc_stream_voronoi_weights: Calculate polyline (e.g. stream) barycentric coordinates

Description Usage Arguments Details Value Author(s) Examples

View source: R/calc_stream_voronoi_weights.R

Description

These coordinates are used as "weights" in the PBJ MODFLOW-USG package to interpolate heads and distribute flows.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
calc_stream_voronoi_weights(
  stream,
  voronoi,
  triangles,
  addTo = NULL,
  geometry = T,
  correct_seg_order = T,
  cutoff_value = 1e-07,
  seg_min_length = 1e-07,
  keep_stream_cols = NULL
)

Arguments

stream

sf polyline, "exploded" into segments (see line_explode)

voronoi

sf polygon of voronoi tesselation (unstructured model grid). Shapefile ID field will be used to determine node ID.

triangles

sf polygon of delaunay triangulation corresponding to voronoi grid.

addTo

(optional) existing calc_stream_voronoi_weights() output new output should be added to (False by default)

geometry

(optional) T/F whether to include sf geometry in output dataframe (default: True)

correct_seg_order

(optional) T/F to re-order the line segments after finding overlaps with the triangle grid. Will crash if you have multiple seperate lines (e.g. two streams). (default: True)

cutoff_value

numeric, minimum barcentric coordinate value. Values below will be forced to zero (1e-7 by default)

seg_min_length

numeric, minimum length of segment to include in calculation (default 1e-7). Generally just to weed out numerical errors.

keep_stream_cols

character array, columns in stream segment dataframe to add to returned dataframe.

Details

The function can take a while to run

Value

DataFrame or sf object, if geometry = True. Each row is one segment-triangle overlap, with six barycentric weights (three for segment end), the three voronoi shape IDs (model nodes) connected by the triangle, and the segment length in the triangle.

This the expected input of stream_elev_from_slope and the calc_conductance* functions (e.g. calc_conductance_modflow)

Author(s)

Leland Scantlebury

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
#-- Read in shapefiles
str <- read_sf(system.file("extdata", "MehlandHill2010_stream.shp", package = "pbjr"))
tri <- read_sf(system.file("extdata", "720_triangles.shp", package = "pbjr"))
vor <- read_sf(system.file("extdata", "720_voronoi.shp", package = "pbjr"))

#-- Explode polyline
str <- line_explode(str)

#-- Run the function
swdf <- calc_stream_voronoi_weights(stream = str, voronoi = vor, triangles = tri)

#-- Example of addTo use (more likely run with new stream shapefile)
more_swdf <- calc_stream_voronoi_weights(stream = str, voronoi = vor, triangles = tri,
                                         addTo = swdf)

scantle/pbjr documentation built on Dec. 22, 2021, 10:19 p.m.