index_points_to_waterbodies: Index Points to Waterbodies

View source: R/index_points_to_lines.R

index_points_to_waterbodiesR Documentation

Index Points to Waterbodies

Description

given an sf point geometry column, return waterbody id, and COMID of dominant artificial path

Usage

index_points_to_waterbodies(
  waterbodies,
  points,
  flines = NULL,
  search_radius = NULL
)

Arguments

waterbodies

sf data.frame of type POLYGON or MULTIPOLYGON including a "wbid" attribute.

points

sfc of type POINT

flines

sf data.frame (optional) of type LINESTRING or MULTILINESTRING including id, wbid, and topo_sort attributes. If omitted, only waterbody indexes are returned.

search_radius

units class with a numeric value indicating how far to search for a waterbody boundary in units of provided projection. Set units with set_units.

Value

data.frame with columns, COMID, in_wb_COMID, near_wb_COMID, near_wb_dist, and outlet_fline_COMID. Distance is in units of provided projection.

Examples


if(require(nhdplusTools)) {

source(system.file("extdata/sample_data.R", package = "nhdplusTools"))

waterbodies <- sf::st_transform(
  sf::read_sf(sample_data, "NHDWaterbody"), 5070)

points <- sf::st_transform(
  sf::st_sfc(sf::st_point(c(-89.356086, 43.079943)),
             crs = 4326), 5070)

index_points_to_waterbodies(waterbodies, points,
                    search_radius = units::set_units(500, "m"))

}


hydroloom documentation built on Sept. 11, 2024, 8:20 p.m.