View source: R/check_topology.R
st_check_junctions | R Documentation |
Check if some road endings are close enough to be considered as being potentially part of a junction.
Road endings that are actually touching are not considered. Fixing can be done by running st_snap_lines
with the same tolerance
value and the same road network.
st_check_junctions(roads, tolerance = 8)
roads |
multiples lines ( |
tolerance |
numeric (distance unit). Tolerance value used to check if some road endings should have been snapped together. |
Polygon object (sf
format) corresponding to circles of tolerance
radius
around the locations where junctions might be missing.
library(sf)
network <- system.file("extdata", "j53e_network.gpkg", package="ALSroads")
network <- st_read(network, "invalid_topology")
junctions <- st_check_junctions(network)
plot(st_geometry(network), axes = TRUE)
plot(st_geometry(junctions), add = TRUE, border = "red")
par(mfrow = c(1,2))
for (k in 1:2)
{
junc <- junctions[k,]
bbox <- st_bbox(junc)
xlim <- bbox[c("xmin", "xmax")]
ylim <- bbox[c("ymin", "ymax")]
sub <- paste0("Connected: ", junc[["nb_connected"]], "\nUnconnected: ", junc[["nb_unconnected"]])
plot(st_geometry(junctions), col = "cyan", xlim = xlim, ylim = ylim, axes = TRUE)
plot(st_geometry(network), col = "red", lwd = 3, add = TRUE)
title(main = k, sub = sub)
}
# simple snapping (see ?st_snap_lines)
network <- st_snap_lines(network)$roads
par(mfrow = c(1,2))
for (k in 1:2)
{
junc <- junctions[k,]
bbox <- st_bbox(junc)
xlim <- bbox[c("xmin", "xmax")]
ylim <- bbox[c("ymin", "ymax")]
sub <- paste0("Connected: ", junc[["nb_connected"]], "\nUnconnected: ", junc[["nb_unconnected"]])
plot(st_geometry(junctions), col = "cyan", xlim = xlim, ylim = ylim, axes = TRUE)
plot(st_geometry(network), col = "red", lwd = 3, add = TRUE)
title(main = k, sub = sub)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.