Open ratnanil opened 1 month ago
related to #49, #29?
Hi @ratnanil and thanks for your question. As described in the introductory vignette,
The most basic way to construct a sfnetwork with spatially explicit edges is by providing the sfnetwork construction function one sf object containing the nodes, and another sf object containing the edges. This edges table should include a from and to column referring to the node indices of the edge endpoints.
Unfortunately, the raw roxel
object does not contain those from
and to
columns and, therefore, the sfnetwork
function cannot build a proper sfnetwork
object. Nevertheless, I think we may provide a better error message.
On the other hand, as_sfnetwork(roxel)
works using a simple heuristic which is described here.
Ah ok, thank you for this explanation, which makes sense. So I could either provide the edges with the from
and to
columns or (as I just realized), split the lines using my explicit nodes and continue as usual:
roxel_split <- lwgeom::st_split(roxel, nodes) |>
st_collection_extract("LINESTRING")
roxel_net <- sfnetworks::as_sfnetwork(roxel_split)
(EDIT: I'll let you close this yourself, after implementing #272)
Describe the bug
I would like to use my own nodes to create my network.
Reproducible example
Created on 2024-07-12 with reprex v2.1.0 Expected behavior
I would have expected that I can provide the network with my own nodes in the function
sfnetwork
. This does not seem to be the case.R Session Info