create_from_spatial_lines: Create a spatial network from linestring geometries

View source: R/create.R

create_from_spatial_linesR Documentation

Create a spatial network from linestring geometries

Description

Create a spatial network from linestring geometries

Usage

create_from_spatial_lines(
  x,
  directed = TRUE,
  compute_length = FALSE,
  subdivide = FALSE
)

Arguments

x

An object of class sf or sfc with LINESTRING geometries.

directed

Should the constructed network be directed? Defaults to TRUE.

compute_length

Should the geographic length of the edges be stored in a column named length? Uses st_length to compute the length of the edge geometries. If there is already a column named length, it will be overwritten. Please note that the values in this column are not automatically recognized as edge weights. This needs to be specified explicitly when calling a function that uses edge weights. Defaults to FALSE.

subdivide

Should the given linestring geometries be subdivided at locations where an interior point is equal to an interior or boundary point in another feature? This will connect the features at those locations. Defaults to FALSE, meaning that features are only connected at their boundaries.

Details

It is assumed that the given linestring geometries form the edges in the network. Nodes are created at the line boundaries. Shared boundaries between multiple linestrings become the same node.

Value

An object of class sfnetwork.

Note

By default sfnetworks rounds coordinates to 12 decimal places to determine spatial equality. You can influence this behavior by explicitly setting the precision of the linestrings using st_set_precision.

See Also

create_from_spatial_points

Examples

library(sf, quietly = TRUE)

oldpar = par(no.readonly = TRUE)
par(mar = c(1,1,1,1), mfrow = c(1,2))

net = as_sfnetwork(roxel)
net

plot(st_geometry(roxel))
plot(net)

par(oldpar)


luukvdmeer/sfnetworks documentation built on Nov. 21, 2024, 4:54 a.m.