Given point features with a known geoconnex mainstem identifier, checks whether the mainstem has been superseded and, if so, re-indexes the point to the replacement mainstem using index_points_to_lines. Points whose mainstem has no replacement are left unchanged and flagged "unresolved". See check_mainstems for a lightweight superseded/current check.

update_mainstems(x, mainstem_col = NULL, search_radius = NULL)

Arguments

x

sf POINT features with a mainstem identifier column.

mainstem_col

character name of the mainstem identifier column in x. Detected automatically from a "mainstemid" or "mainstem_id" column if not provided. Values may be bare ref/mainstems ids or full mainstem uris (any namespace); see check_mainstems.

search_radius

units distance for the nearest neighbor search passed to index_points_to_lines. If NULL, the default in index_points_to_lines is used.

Value

x with mainstem_col updated in place and a mainstem_update_status column added with values "unchanged", "updated", or "unresolved".

Examples

# \donttest{
pt <- sf::st_sf(mainstemid = 2086165,
                geometry = sf::st_sfc(sf::st_point(c(-75.567, 43.176)),
                                      crs = 4326))
update_mainstems(pt)
#> Warning: no non-missing arguments to min; returning Inf
#> Warning: Some mainstem ids could not be resolved to a replacement. See mainstem_update_status column.
#> Simple feature collection with 1 feature and 2 fields
#> Geometry type: POINT
#> Dimension:     XY
#> Bounding box:  xmin: -75.567 ymin: 43.176 xmax: -75.567 ymax: 43.176
#> Geodetic CRS:  WGS 84
#>   mainstemid               geometry mainstem_update_status
#> 1    2086165 POINT (-75.567 43.176)             unresolved
# }