Questions tagged [sfnetwork]

Package website

Github repository

Related tags

31 questions
6
votes
1 answer

Using R package sfnetworks to subset river network that is upstream of a given node

I'm experimenting with using the sfnetworks package to query river networks. Specifically, I'd like to subset upstream portions of a river network relative to any given site. I have a small river network dataset (available here) that I can convert…
mbcaradima
  • 251
  • 2
  • 11
2
votes
0 answers

Building sfnetwork in R throwing an error message

I am trying to build a road network by using sfnetworks package in R, and I ran into an issue while running the last code chunk. The below is my R code and data available here: # Read in Data ## London borough boundary LondonBoroughs <-…
Phil
  • 37
  • 5
2
votes
1 answer

nearest neighbour join between two sfc_LINESTRING objects

I have two adjacent areas, on which I have a connected grid that each take the structure of sfc_LINESTRING. One area is larger and has a coarser grid, and the other is smaller with a finer grid. I want to be able to do a join so at least one of the…
colebrookson
  • 831
  • 7
  • 18
2
votes
1 answer

Create subgraph from shortest path calculation sfnetworks R

I have a network, and a focal node within the network. I have calculated the shortest paths to all other nodes from that node, and I'm trying to figure out how to make a sub-graph of the original network from that shortest path calculation. The goal…
colebrookson
  • 831
  • 7
  • 18
2
votes
1 answer

Calculating Distances Between Points on a Shapefile

I am working with the R programming language. I am interested in learning about how to calculate the driving distance (e.g. based on road networks) between two sets of coordinates. For example: CN Tower: 290 Bremner Blvd, Toronto, ON M5V 3L9…
stats_noob
  • 5,401
  • 4
  • 27
  • 83
2
votes
1 answer

[R-iGraph-Sfnetwork]: Is it possible to optimize this code for setting new weight in SfNetwork / iGraph

While profiling my code I discovered that the part that sets the new weight in a graph takes the most time to run. Since I have to do it repeatedly on much bigger graph than in this example, the running time adds up. Is it possible to optimize…
Andreas
  • 397
  • 4
  • 18
  • 37
2
votes
1 answer

Retain sf point columns after st_network_blend()

I have an sfnetwork (net) and pts that I am combining using st_network_blend(). After calculating some new attributes for these points I would like to extract them and regain the columns of the original points. A spatial join using st_join won't…
Josh J
  • 395
  • 1
  • 3
  • 13
2
votes
1 answer

R: Return list of edges of all simple paths

I am trying to obtain edge lists of paths between two nodes using tidygraph. Here is an example demo <- tbl_graph(nodes = tibble(name = c("A", "B", "C", "D")), edges = tribble(~from, ~to,~id, …
Qzhao
  • 57
  • 3
2
votes
1 answer

Creating a inla.graph object with correct index labels from sf linestring object

I have a shapefile containing linestrings that describes connection between cities in Brazil. I would like to convert these connections into a neighbourhood object with the cities' code set as the row name, making it compatible with my data frame: >…
2
votes
0 answers

Sequencing of river network calculation using sfnetworks and r

I’ve got a rooted tree setup in sfnetworks. It is derived from a line shapefile of a stream network. For each tributary in the stream network, there are obviously start and end nodes which sfnetworks determines, but there are also nodes connecting…
Scott R
  • 21
  • 3
2
votes
1 answer

Split linestring with points and assign new segment ID in R

I am trying to split a river (lines) using dams (points) into connected segments between the dams. The answer here is the closest to what I'm trying to achieve. The problem is that st_split uses the polygon boundaries as the 'blade' thus splitting…
Josh J
  • 395
  • 1
  • 3
  • 13
1
vote
1 answer

st_network_blend does not include all points

I would like to do a bending between the network Riv and the points df with the function library(sf) net <- as_sfnetwork(Riv) |> st_network_blend(df) Nevertheless in this exemple, two points are removed in the output (38, 120). I am looking for a…
C. Guff
  • 418
  • 3
  • 18
1
vote
1 answer

Distance between points along path in R

I want to compute distance between nodes along a path (network). I have two shapefiles. One is a point layer representing train stations: train_station <- structure(list(geometry = structure(list(structure(c(1789781.1763, 1036140.3792), class =…
1
vote
1 answer

[R/igraph]: Select a path from a nested list of paths based on first and last node

I calculate a nested list of all possible paths of a given length in a graph and would like to select only certain paths´s based on first and last element value of the path. Here is what I do: First I create a graph library(sfnetworks) net =…
Andreas
  • 397
  • 4
  • 18
  • 37
1
vote
1 answer

Filling road network data gaps

I have a motorway network with count points that can be matched to road links. However, they only match around half the osm links. The network is uni directional and it should be possible to assign data from joining links to the missing links. I…
Blaiso
  • 165
  • 9
1
2 3