| Title: | Identify Naturally Continuous Lines in a Spatial Network |
|---|---|
| Description: | Provides functionality to group lines that form naturally continuous lines in a spatial network. The algorithm implemented is based on the Continuity in Street Networks (COINS) method from Tripathy et al. (2021) <doi:10.1177/2399808320967680>, which identifies continuous "strokes" in the network as the line strings that maximize the angles between consecutive segments. |
| Authors: | Francesco Nattino [aut, cre, cph] (ORCID: <https://orcid.org/0000-0003-3286-0139>), Claudiu Forgaci [aut] (ORCID: <https://orcid.org/0000-0003-3218-5102>), Fakhereh Alidoost [aut] (ORCID: <https://orcid.org/0000-0001-8407-6472>), Thijs van Lankveld [ctb] (ORCID: <https://orcid.org/0009-0001-1147-4813>), Netherlands eScience Center [fnd] |
| Maintainer: | Francesco Nattino <[email protected]> |
| License: | Apache License (>= 2) |
| Version: | 0.4.0 |
| Built: | 2026-05-19 06:04:20 UTC |
| Source: | https://github.com/cityriverspaces/rcoins |
This function retrieves example OpenStreetMap (OSM) data from the Zenodo data repository, and it can be used in examples and tests. The code used to generate the example dataset is available at https://github.com/CityRiverSpaces/CRiSpExampleData. Note that the example dataset is cached locally, so that subsequent calls to the function can load the example data from disk without having to re-download the data.
get_example_data()get_example_data()
A list of sf objects containing the OSM data as sf::sfc
objects.
get_example_data()get_example_data()
Provides functionality to group lines that form naturally continuous lines in a spatial network. The algorithm implemented is based on the Continuity in Street Networks (COINS) method https://doi.org/10.1177/2399808320967680, which identifies continuous "strokes" in the network as the line strings that maximize the angles between consecutive segments.
stroke( edges, angle_threshold = 0, attributes = FALSE, flow_mode = FALSE, from_edge = NULL )stroke( edges, angle_threshold = 0, attributes = FALSE, flow_mode = FALSE, from_edge = NULL )
edges |
An object of class |
angle_threshold |
Consecutive line segments can be considered part of
the same stroke if the internal angle they form is larger than
|
attributes |
If |
flow_mode |
If |
from_edge |
Only look for the continuous strokes that include the provided edges or line segments. |
An object of class sfc (if
attributes = FALSE), a vector with the same length as edges
otherwise.
library(sf) # Setup a simple network p1 <- st_point(c(0, 3)) p2 <- st_point(c(2, 1)) p3 <- st_point(c(3, 0)) p4 <- st_point(c(1, 4)) p5 <- st_point(c(3, 2)) p6 <- st_point(c(4, 1)) p7 <- st_point(c(4, 3)) p8 <- st_point(c(5, 3)) l1 <- st_linestring(c(p1, p2, p5)) l2 <- st_linestring(c(p2, p3)) l3 <- st_linestring(c(p4, p5)) l4 <- st_linestring(c(p5, p6)) l5 <- st_linestring(c(p5, p7)) l6 <- st_linestring(c(p7, p8)) network_edges <- st_sfc(l1, l2, l3, l4, l5, l6) # Identify strokes in the full network with default settings stroke(network_edges) # Set a threshold to the angle between consecutive segments stroke(network_edges, angle_threshold = 150) # Identify strokes in flow mode (do not break initial edges) stroke(network_edges, flow_mode = TRUE) # Instead of returning stroke geometries, return stroke labels stroke(network_edges, flow_mode = TRUE, attributes = TRUE) # Identify strokes that continue one (or a subset) of edges stroke(network_edges, from_edge = 2) stroke(network_edges, from_edge = c(2, 3))library(sf) # Setup a simple network p1 <- st_point(c(0, 3)) p2 <- st_point(c(2, 1)) p3 <- st_point(c(3, 0)) p4 <- st_point(c(1, 4)) p5 <- st_point(c(3, 2)) p6 <- st_point(c(4, 1)) p7 <- st_point(c(4, 3)) p8 <- st_point(c(5, 3)) l1 <- st_linestring(c(p1, p2, p5)) l2 <- st_linestring(c(p2, p3)) l3 <- st_linestring(c(p4, p5)) l4 <- st_linestring(c(p5, p6)) l5 <- st_linestring(c(p5, p7)) l6 <- st_linestring(c(p7, p8)) network_edges <- st_sfc(l1, l2, l3, l4, l5, l6) # Identify strokes in the full network with default settings stroke(network_edges) # Set a threshold to the angle between consecutive segments stroke(network_edges, angle_threshold = 150) # Identify strokes in flow mode (do not break initial edges) stroke(network_edges, flow_mode = TRUE) # Instead of returning stroke geometries, return stroke labels stroke(network_edges, flow_mode = TRUE, attributes = TRUE) # Identify strokes that continue one (or a subset) of edges stroke(network_edges, from_edge = 2) stroke(network_edges, from_edge = c(2, 3))