Skip to content

lnk_points_snap(): wrap or retire in favour of the bulk fresh::frs_point_snap() #314

Open

Description

@NewGraphEnvironment

fresh#247 makes fresh::frs_point_snap() a bulk snap (fresh 0.40.0). It takes a table, a data frame or an sf object and runs one lateral nearest-neighbour query. With to = it writes the result to a table. It returns watershed_group_code, and its candidates and measures match lnk_points_snap(). On all 19,905 PSCIS crossings at 150 m:

  • 18,180 picks are identical.
  • 22 are equidistant ties: a point sits on the vertex between two segments of the same stream, and the measures land 1 m apart.
  • 11 picked a placeholder segment (lnk_points_snap() can snap to placeholder (999.*) stream segments #313).
  • There are no other differences. At num_features = 5 the candidate sets and measures agree too.

The comparison script is data-raw/point_snap_parity_check.R in fresh.

Proposal

Make lnk_points_snap() a thin wrapper, or deprecate it and call fresh directly:

fresh::frs_point_snap(conn, table_in, col_id = "<id>",
  tolerance = snap_tolerance, num_features = num_features,
  col_blk = blue_line_key_col, stream_order_min = stream_order_min,
  exclude_edge_types = exclude_edge_types, to = table_out)

Then join pts.* back on the id if callers need the input columns.

Differences to handle

  • fresh returns blue_line_key and geom. link returns snapped_blue_line_key and geom_snapped.
  • fresh needs a unique, non-missing id column (col_id) for a table input.
  • A missing per-row hint leaves that point unconstrained in fresh. In link, s.blue_line_key = pts.<col> drops the row.
  • fresh breaks distance ties on linear_feature_id. link has no tie-break.
  • The roxygen at R/lnk_points_snap.R:52 refers to fresh::frs_point_snap_knn, which no longer exists.

Relates to NewGraphEnvironment/fresh#247, #283.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions