Skip to contents

Give a set of transecct linestrings and poylgons and get the minimum distance to extend each transect line (from both directions, to try and reach the edge of a "polygons") Superseces old version of function (now named extend_transects_to_polygons2())

Usage

extend_transects_to_polygons(
  transect_lines,
  polygons,
  flowlines,
  crosswalk_id = "hy_id",
  grouping_id = "mainstem",
  max_extension_distance = 3000,
  keep_lengths = FALSE,
  reindex_cs_ids = TRUE
)

Arguments

transect_lines

Set of Sf linestrings to extend (only if the transect lines are ENTIRELLY within a polygons)

polygons

set of sf polygons that transect lines should be exteneded

flowlines

set of Sf linestrings

crosswalk_id

character, flowline ID that matches flowlines with transect lines. This crosswalk_id must appear are a column in both flowlines and transect_lines.

grouping_id

character, name of a column in flowlines that should be used to group each transect with 1 or more flowlines. That is, when transects are checked to make sure they don't intersect other transects or other flowlines, this group ID will distinguise which flowlines a transect should be checked against. The intersect_group_id must appear as a column in both flowlines and transect_lines dataframes

max_extension_distance

numeric, maximum distance (meters) to extend a transect line in either direction to try and intersect one of the "polygons". Default is 3000m

keep_lengths

logical whether to keep a record of the original transect lengths or not, default is FALSE, original lengths are not kept

reindex_cs_ids

logical, whether to reindex the cs_ids to ensure each crosswalk_id has cs_ids of 1-number of transects. Default is TRUE, which makes sure if any cross sections were removed from a crosswalk_id, then the cs_ids are renumbered so there are no gaps between cs_ids within a crosswalk_id. Setting this to FALSE will make sure crosswalk_id/cs_ids remain untouched as they were given in the input data.

Value

sf linestring, with extended transect lines