graph_lines() draws each edge of a unit_graph() as a line between
the centroids of its two units, so the graph can be checked in a GIS
over the units. A missing edge shows where two units that should touch
do not, and a crossing shows where a barrier cut them apart.
Arguments
- graph
A
unit_graph().- group
The group of each unit, or
NULL(default). With it, each line records whether it joins two groups.
Value
An sf object of lines in the CRS of the graph, one per edge
and per barrier crossing, holding from, to, shared, kind
("edge" or "crossing"), visible for edges of a graph built with
visible lines, and between when group is given.
See also
Other checks:
audit_field(),
check_groups(),
check_units(),
group_metrics()
Examples
cells <- sf::st_make_grid(
sf::st_bbox(c(xmin = 0, ymin = 0, xmax = 300, ymax = 200)),
cellsize = 100
)
cells <- sf::st_sf(geometry = cells, crs = 32630)
road <- sf::st_sfc(
sf::st_linestring(rbind(c(100, 0), c(100, 200))),
crs = 32630
)
g <- unit_graph(cells, barrier = road)
graph_lines(g)
#> Simple feature collection with 7 features and 4 fields
#> Geometry type: LINESTRING
#> Dimension: XY
#> Bounding box: xmin: 50 ymin: 50 xmax: 250 ymax: 150
#> Projected CRS: WGS 84 / UTM zone 30N
#> from to shared kind geometry
#> 1 1 4 100 edge LINESTRING (50 50, 50 150)
#> 2 2 3 100 edge LINESTRING (150 50, 250 50)
#> 3 2 5 100 edge LINESTRING (150 50, 150 150)
#> 4 3 6 100 edge LINESTRING (250 50, 250 150)
#> 5 5 6 100 edge LINESTRING (150 150, 250 150)
#> 6 1 2 100 crossing LINESTRING (50 50, 150 50)
#> 7 4 5 100 crossing LINESTRING (50 150, 150 150)