lines_to_lsn_temp {SSNbler}R Documentation

Convert lines to a landscape network

Description

Convert an sf object containing features with LINESTRING geometry to a landscape network (LSN), which is a topological data model of streams/rivers represented as a directional graph embedded in 2-D geographic space. Relationship tables are created and topological relationships are checked.

Usage

lines_to_lsn_temp(
  streams,
  lsn_path,
  snap_tolerance = 0,
  topo_tolerance = 0,
  check_topology = TRUE,
  remove_ZM = FALSE,
  overwrite = FALSE,
  verbose = TRUE
)

Arguments

streams

An sf object with LINESTING geometry representing streams.

lsn_path

Pathname to a directory in character format specifying where to store the outputs. The directory will be created if it does not already exist.

snap_tolerance

Distance in map units. Two nodes separated by a distance less than or equal to snap_tolerance are assumed to be connected. Defaults to 0.

topo_tolerance

Distance in map units. Only used if check_topology = TRUE. Two nodes on the network separated by a distance less than or equal to topo_tolerance are flagged as potential topological errors in the network. Defaults to 0.

check_topology

Logical. If TRUE, the edges will be checked for topological errors and potential node errors will be flagged in an output file called node_errors.gpkg. Defaults to TRUE.

remove_ZM

Logical. If TRUE, Z and M dimensions are removed from streams, if they exist. Default is FALSE.

overwrite

Logical. If TRUE, output files will overwrite existing files with the same names. If FALSE and files sharing the same names as the outputs exist in the lsn_path, the function will exit early with an error.

verbose

Logical. If TRUE, messages describing function progress will be printed to the console. Default is TRUE.

Details

lines_to_lsn converts an sf object representing streams to a landscape network (LSN), which is a directional graph used to represent the topological and geographic relationships between line features, along with additional attribute information. streams must have LINESTRING geometry and a projected coordinate system, rather than geographic coordinate system (i.e. not Longitude and Latitude).

The LSN is saved to a local directory defined by lsn_path and has 5 components:

Topological errors are common in spatial data and must be corrected to ensure that the LSN accurately represents direction and connectivity within the stream network. When check_topology = TRUE, the edges are checked for topological errors. Two nodes on the network separated by a distance less than or equal to topo_tolerance are flagged as potential topological errors in the network saved in an output file called node_errors.gpkg, which is also saved to lsn_path. In addition to the pointid, node_errors.gpkg contains a column containing the node class (nodecat), which can take on values of Pseudonode, Confluence, Source, or Outlet. A second column (error) defines the potential error type and can take on values of Complex Confluence, Converging Node, Dangling Node, Intersection Without Node, Downstream Divergence and Unsnapped Node. The nodecat column is also added to nodes.gpkg. A node_errors.gpkg file is not produced if no obvious errors are identified. There is no guarantee that all topological errors will be identified and included in node_errors.gpkg. Therefore, potential errors and node classes found in node_errors.gpkg and nodes.gpkg must be checked in a GIS and topological errors in streams corrected before rebuilding the LSN using lines_to_lsn(). This process is iterative and must continue until the LSN is free of topological errors.

Value

An sf object representing edges in the LSN. The LSN, including edges.gpkg, nodes.gpkg, nodexy.csv, noderelationships.csv, and relationships.csv files, are saved locally to a directory defined by lsn_path. If check_topology = TRUE and topological errors are identified, then node_errors.gpkg is also saved to lsn_path.


[Package SSNbler version 1.0.1 Index]