luukvdmeer / sfnetworks

Tidy Geospatial Networks in R
https://luukvdmeer.github.io/sfnetworks/
Other
347 stars 20 forks source link

Validation functions for sfnetworks #93

Open luukvdmeer opened 3 years ago

luukvdmeer commented 3 years ago

Is your feature request related to a problem? Please describe. When creating an sfnetwork from nodes and edges, it is checked if the network is valid. For the nodes, this means that they all should have point geometries. In the case of spatially explicit edges, it is also checked that all edges have linestring geometries, nodes and edges have the same CRS and boundary points of edges match their corresponding node coordinates.

If the structure is not valid, an error is raised, but the user has no insight on where exactly the invalidity occurred. We have several internal functions in the package that do the checks. For example, for directed networks nodes_match_edge_boundaries will check if the coordinates of the edge boundaries match their corresponding nodes, and for undirected networks, nodes_in_edge_boundaries will check if the coordinates of the edge boundaries match either one of the from or to node. All this is currently hidden for the user.

Describe the solution you'd like Exporting such functions (either directly or in some st_is_network_valid format) will give users better insight in where their network has errors. Also, we could think of an st_make_network_valid function that automatically fixes (some of) the errors.