These functions are a collection of specific spatial edge measures, that
form a spatial extension to edge measures in
tidygraph
.
edge_azimuth(degrees = FALSE)
edge_circuity(Inf_as_NaN = FALSE)
edge_length()
edge_displacement()
A numeric vector of the same length as the number of edges in the graph.
Just as with all query functions in tidygraph, spatial edge
measures are meant to be called inside tidygraph verbs such as
mutate
or filter
, where
the network that is currently being worked on is known and thus not needed
as an argument to the function. If you want to use an algorithm outside of
the tidygraph framework you can use with_graph
to
set the context temporarily while the algorithm is being evaluated.
edge_azimuth()
: The angle in radians between a straight
line from the edge startpoint pointing north, and the straight line from
the edge startpoint and the edge endpoint. Calculated with
st_geod_azimuth
. Requires a geographic CRS.
edge_circuity()
: The ratio of the length of an edge
linestring geometry versus the straight-line distance between its boundary
nodes, as described in Giacomin &
Levinson, 2015. DOI: 10.1068/b130131p.
edge_length()
: The length of an edge linestring geometry
as calculated by st_length
.
edge_displacement()
: The straight-line distance between the two
boundary nodes of an edge, as calculated by st_distance
.
library(sf, quietly = TRUE)
library(tidygraph, quietly = TRUE)
net = as_sfnetwork(roxel)
net %>%
activate("edges") %>%
mutate(azimuth = edge_azimuth())
#> # A sfnetwork with 701 nodes and 851 edges
#> #
#> # CRS: EPSG:4326
#> #
#> # A directed multigraph with 14 components with spatially explicit edges
#> #
#> # Edge data: 851 × 6 (active)
#> from to name type geometry azimuth
#> <int> <int> <chr> <fct> <LINESTRING [°]> [rad]
#> 1 1 2 Havixbecker Strasse residenti… (7.533722 51.95556, 7.53… -0.670
#> 2 3 4 Pienersallee secondary (7.532442 51.95422, 7.53… -2.91
#> 3 5 6 Schulte-Bernd-Strasse residenti… (7.532709 51.95209, 7.53… 0.203
#> 4 7 8 NA path (7.540063 51.94468, 7.53… -0.968
#> 5 9 10 Welsingheide residenti… (7.537673 51.9475, 7.537… -3.12
#> 6 11 12 NA footway (7.543791 51.94733, 7.54… -3.10
#> # ℹ 845 more rows
#> #
#> # Node data: 701 × 1
#> geometry
#> <POINT [°]>
#> 1 (7.533722 51.95556)
#> 2 (7.533461 51.95576)
#> 3 (7.532442 51.95422)
#> # ℹ 698 more rows
net %>%
activate("edges") %>%
mutate(azimuth = edge_azimuth(degrees = TRUE))
#> # A sfnetwork with 701 nodes and 851 edges
#> #
#> # CRS: EPSG:4326
#> #
#> # A directed multigraph with 14 components with spatially explicit edges
#> #
#> # Edge data: 851 × 6 (active)
#> from to name type geometry azimuth
#> <int> <int> <chr> <fct> <LINESTRING [°]> [°]
#> 1 1 2 Havixbecker Strasse residenti… (7.533722 51.95556, 7.53… -38.4
#> 2 3 4 Pienersallee secondary (7.532442 51.95422, 7.53… -167.
#> 3 5 6 Schulte-Bernd-Strasse residenti… (7.532709 51.95209, 7.53… 11.6
#> 4 7 8 NA path (7.540063 51.94468, 7.53… -55.4
#> 5 9 10 Welsingheide residenti… (7.537673 51.9475, 7.537… -179.
#> 6 11 12 NA footway (7.543791 51.94733, 7.54… -177.
#> # ℹ 845 more rows
#> #
#> # Node data: 701 × 1
#> geometry
#> <POINT [°]>
#> 1 (7.533722 51.95556)
#> 2 (7.533461 51.95576)
#> 3 (7.532442 51.95422)
#> # ℹ 698 more rows
net %>%
activate("edges") %>%
mutate(circuity = edge_circuity())
#> # A sfnetwork with 701 nodes and 851 edges
#> #
#> # CRS: EPSG:4326
#> #
#> # A directed multigraph with 14 components with spatially explicit edges
#> #
#> # Edge data: 851 × 6 (active)
#> from to name type geometry circuity
#> <int> <int> <chr> <fct> <LINESTRING [°]> <dbl>
#> 1 1 2 Havixbecker Strasse resident… (7.533722 51.95556, 7.53… 1
#> 2 3 4 Pienersallee secondary (7.532442 51.95422, 7.53… 1.01
#> 3 5 6 Schulte-Bernd-Strasse resident… (7.532709 51.95209, 7.53… 1.00
#> 4 7 8 NA path (7.540063 51.94468, 7.53… 1.01
#> 5 9 10 Welsingheide resident… (7.537673 51.9475, 7.537… 1
#> 6 11 12 NA footway (7.543791 51.94733, 7.54… 1.02
#> # ℹ 845 more rows
#> #
#> # Node data: 701 × 1
#> geometry
#> <POINT [°]>
#> 1 (7.533722 51.95556)
#> 2 (7.533461 51.95576)
#> 3 (7.532442 51.95422)
#> # ℹ 698 more rows
net %>%
activate("edges") %>%
mutate(length = edge_length())
#> # A sfnetwork with 701 nodes and 851 edges
#> #
#> # CRS: EPSG:4326
#> #
#> # A directed multigraph with 14 components with spatially explicit edges
#> #
#> # Edge data: 851 × 6 (active)
#> from to name type geometry length
#> <int> <int> <chr> <fct> <LINESTRING [°]> [m]
#> 1 1 2 Havixbecker Strasse residential (7.533722 51.95556, 7.53… 28.8
#> 2 3 4 Pienersallee secondary (7.532442 51.95422, 7.53… 108.
#> 3 5 6 Schulte-Bernd-Strasse residential (7.532709 51.95209, 7.53… 54.3
#> 4 7 8 NA path (7.540063 51.94468, 7.53… 155.
#> 5 9 10 Welsingheide residential (7.537673 51.9475, 7.537… 209.
#> 6 11 12 NA footway (7.543791 51.94733, 7.54… 63.0
#> # ℹ 845 more rows
#> #
#> # Node data: 701 × 1
#> geometry
#> <POINT [°]>
#> 1 (7.533722 51.95556)
#> 2 (7.533461 51.95576)
#> 3 (7.532442 51.95422)
#> # ℹ 698 more rows
net %>%
activate("edges") %>%
mutate(displacement = edge_displacement())
#> # A sfnetwork with 701 nodes and 851 edges
#> #
#> # CRS: EPSG:4326
#> #
#> # A directed multigraph with 14 components with spatially explicit edges
#> #
#> # Edge data: 851 × 6 (active)
#> from to name type geometry displacement
#> <int> <int> <chr> <fct> <LINESTRING [°]> [m]
#> 1 1 2 Havixbecker Strasse resi… (7.533722 51.95556, 7.53… 28.8
#> 2 3 4 Pienersallee seco… (7.532442 51.95422, 7.53… 107.
#> 3 5 6 Schulte-Bernd-Strasse resi… (7.532709 51.95209, 7.53… 54.3
#> 4 7 8 NA path (7.540063 51.94468, 7.53… 154.
#> 5 9 10 Welsingheide resi… (7.537673 51.9475, 7.537… 209.
#> 6 11 12 NA foot… (7.543791 51.94733, 7.54… 61.7
#> # ℹ 845 more rows
#> #
#> # Node data: 701 × 1
#> geometry
#> <POINT [°]>
#> 1 (7.533722 51.95556)
#> 2 (7.533461 51.95576)
#> 3 (7.532442 51.95422)
#> # ℹ 698 more rows