Finds the stretch of another network's flowlines (NHDPlusV2, NHDPlusHR, or 3DHP) that covers each given flowline, on the same mainstem. Each source flowline comes back as one or more pieces of target flowlines, each cut by measure.

translate_flowlines(
  ids,
  from,
  to,
  snap_m = 50,
  search_radius = units::set_units(1000, "m"),
  precision = 10
)

Arguments

ids

vector of source flowline identifiers: comids for "nhdpv2", NHDPlusIDs for "nhdphr", or id3dhp for "3dhp".

from

character network x is indexed to, one of "nhdpv2", "nhdphr", or "3dhp".

to

character network to place x on, one of "nhdpv2", "nhdphr", or "3dhp".

snap_m

numeric meters, passed to get_subpath.

search_radius

units distance passed to index_points_to_lines, in a linear unit since indexing is in EPSG:5070. Only flowlines of the point's own mainstem are searched, so the radius can be wide enough to span differences between networks, such as a reservoir that one network routes differently from another.

precision

numeric meters, passed to index_points_to_lines. Lines near each point are segmentized to this spacing so the match is to the nearest point on a line, not the nearest vertex; NA matches vertices only.

Value

data.frame with line_id (the source id), segment_order (1 at the downstream end), id (target flowline), id_from_measure, id_to_measure, line_from_measure, line_to_measure, length_km, from_offset, to_offset, status, and measured_on; an sf data.frame of piece geometry when lwgeom is installed.

Details

The mainstem of each source flowline comes from its identifier, as described in translate_hydrolocations. The source and target flowlines of that mainstem come from get_mainstem_flowlines.

The downstream (end) and upstream (start) nodes of each source flowline are indexed to the target flowlines of its mainstem with index_points_to_lines and aggregate_ids, and the stretch between them is taken with get_subpath. An end within snap_m meters of a target flowline boundary moves to that boundary, so two source flowlines that share a node share one cut. line_from_measure and line_to_measure place each piece along the source flowline, 0 at its downstream end, by the pieces' lengths. from_offset and to_offset are the distances from the source flowline's downstream and upstream nodes to the target flowlines, in meters (indexing is in EPSG:5070, as in translate_hydrolocations).

status is one of: placed; inverted (the source flowline's downstream node is upstream of its upstream node on the target); collapsed (both ends land on one point, one row with NA id); not_placed (an end has no target flowline within search_radius); no_mainstem; mainstem_superseded; source_not_found (the source flowline is not among the fetched flowlines of its mainstem); and mainstem_not_in_target. Rows that are not placed have NA pieces. measured_on is as described in translate_hydrolocations. The reverse translation is the same call with from and to swapped.

The ref_rivers lookup tables are large downloads on first use (see add_mainstems), so this function has no example.


translate_flowlines(8894344, "nhdpv2", "3dhp")