You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am working on a project that requires me to remove road segments based on a set of lat/lons. To do so, I exported a weighted streetnet as an sf object so that I could identify the appropriate segments to remove using spatial queries.
I had initially done testing using the built-in hampi streetnet to ensure that the edge_ids remain consistent between the contracted graph and the sf object, and I determined that they were. For instance, in the case below, both tests return TRUE only
library(dodgr)
library(sf)
library(tidyverse)
#general hampi streetnetwork
hampi_general <- weight_streetnet(hampi)
#contracted
contracted_general <- dodgr_contract_graph(hampi_general)
#sf version
sf_general <- dodgr_to_sf(hampi_general) %>% st_drop_geometry()
#test if edge ids in both
unique(contracted_general$edge_id %in% sf_general$edge_id)
#test if rows are identical
unique(do.call(paste0, contracted_general) %in% do.call(paste0, sf_general))
However, when trying to remove the edges from my own network, I discovered that they actually did not remain consistent. Subsequently I discovered that when using a weighting profile, edge_ids no longer remain consistent between the contracted graph and the sf object. For instance, in the case below, both tests return TRUE and FALSE
hampi_motorcar <- weight_streetnet(hampi, wt_profile = "motorcar")
contracted_motorcar <- dodgr_contract_graph(hampi_motorcar)
sf_motorcar <- dodgr_to_sf(hampi_motorcar) %>% st_drop_geometry()
#test if edge ids in both
unique(contracted_motorcar$edge_id %in% sf_motorcar$edge_id)
#test if rows are identical
unique(do.call(paste0, contracted_motorcar) %in% do.call(paste0, sf_motorcar))
However, it seems that when even using a weighting profile, the from_id and to_id remain consistent
Sorry @jucardwell that this issue slipped through the gaps for such a long time 😱. The resolution to your problem is that "edge_id" values only mean something within one single graph, and should never be used to compare graphs. The fact that the first example generates identical edge id values should be considered an accident. (This case will only arise when graph contraction produces the exact format required for representation as sf LINESTRING objects, which is not always the case.)
Hi,
I am working on a project that requires me to remove road segments based on a set of lat/lons. To do so, I exported a weighted streetnet as an sf object so that I could identify the appropriate segments to remove using spatial queries.
I had initially done testing using the built-in hampi streetnet to ensure that the edge_ids remain consistent between the contracted graph and the sf object, and I determined that they were. For instance, in the case below, both tests return TRUE only
However, when trying to remove the edges from my own network, I discovered that they actually did not remain consistent. Subsequently I discovered that when using a weighting profile, edge_ids no longer remain consistent between the contracted graph and the sf object. For instance, in the case below, both tests return TRUE and FALSE
However, it seems that when even using a weighting profile, the from_id and to_id remain consistent
The text was updated successfully, but these errors were encountered: