Closed mem48 closed 2 years ago
Oh yeah, good catch. That's an even more pervasive issue that just that function, and actually arises there because dodgr_contract_graph
behaves the same way. They both just need a keep_cols
parameter to control that, which I'll implement pronto.
No, all columns are kept automatically, but it's a glitch in the caching system, so that dodgr_to_sf()
is just grabbing a version which has been automatically cached prior to adding centrality
. That means a workaround here is to do this:
library(dodgr)
graph <- weight_streetnet (hampi)
graph <- dodgr_centrality(graph)
gsf <- dodgr_to_sf(graph)
#> Loading required namespace: sf
names (gsf)
#> [1] "geom_num" "edge_id" "from_id" "from_lon"
#> [5] "from_lat" "to_id" "to_lon" "to_lat"
#> [9] "d" "d_weighted" "highway" "way_id"
#> [13] "time" "time_weighted" "component" "geometry"
clear_dodgr_cache ()
gsf <- dodgr_to_sf(graph)
names (gsf)
#> [1] "geom_num" "edge_id" "from_id" "from_lon"
#> [5] "from_lat" "to_id" "to_lon" "to_lat"
#> [9] "d" "d_weighted" "highway" "way_id"
#> [13] "time" "time_weighted" "centrality" "component"
#> [17] "geometry"
Created on 2020-06-25 by the reprex package (v0.3.0)
Proper fix will come soon.
@mem48 took ages, but fixed now. Thanks as always!
dodgr_to_sf
drops the results of an analysisFor example:
The
centrality
column has been lost which is what I wanted.