vegnett_to_R | R Documentation |
The function vegnett_to_R
can be used to convert the Norwegian road network, downloaded from Geonorge, to formats that enable network analysis in R (tbl_graph
and cppRouting
).
vegnett_to_R( vegnett, crs_out = 25833, year = 2022, fromnodeID = "FROMNODE", tonodeID = "TONODE", FT_minutes = "DRIVETIME_FW", TF_minutes = "DRIVETIME_BW", meters = "SHAPE_LENGTH", turn_restrictions = FALSE, ferry = TRUE )
vegnett |
The Norwegian road network as an |
crs_out |
Numeric vector with the chosen coordinate reference system (CRS). The default value is set to |
year |
Numeric vector with the year the road network is from. Due to changes in the format of the files between 2021 and 2022, the most important thing is to choose between the "old" format (-2021) or the new format (2022-). The default value is set to 2022. Please see the example for the column names for 2021 and earlier. |
fromnodeID |
Character vector with the name of the column indicating the from node ID. Default value is set to |
tonodeID |
Character vector with the name of the column indicating the to node ID. Default value is set to |
FT_minutes |
Character vector with the name of the column that contains the cost in minutes from |
TF_minutes |
Character vector with the name of the column that contains the cost in minutes from |
meters |
Character vector with the name of the column that contains the cost in meters (equal for FT and TF). Default value is set to |
turn_restrictions |
Logical. Default value is |
ferry |
Logical/numeric vector. Default value is |
List containing the following elements:
[1] graph
: the road network structured as a tidy graph (tbl_graph
object).
[2] nodes
: the road network's nodes (sf
object).
[3] edges
: road network's edges/node links (data.frame
).
[4] graph_cppRouting_minutes
: the road network structured as a cppRouting
graph with the cost of travel in minutes (cppRouting
object).
[5] graph_cppRouting_meters
: the road network structured as a cppRouting
graph with the cost of travel in meters (cppRouting
object).
vegnett_sampledata vegnett_list <- vegnett_to_R(vegnett = vegnett_sampledata, year = 2021, fromnodeID = "FROMNODEID", tonodeID = "TONODEID", FT_minutes = "FT_MINUTES", TF_minutes = "TF_MINUTES", meters = "SHAPE_LENGTH") graph <- vegnett_list[[1]] nodes <- vegnett_list[[2]] edges <- vegnett_list[[3]] graph_cppRouting_minutes <- vegnett_list[[4]] graph_cppRouting_meters <- vegnett_list[[5]] graph nodes head(edges) head(graph_cppRouting_minutes$data) head(graph_cppRouting_minutes$coords) head(graph_cppRouting_minutes$dict) graph_cppRouting_minutes$nbnode head(graph_cppRouting_meters$data) head(graph_cppRouting_meters$coords) head(graph_cppRouting_meters$dict) graph_cppRouting_meters$nbnode
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.