network.layout.extract_coordinates {netmap}R Documentation

Layout of a network based on a sf object

Description

Custom layout for plot.network, extracting coordinates of vertices from a sf object. Its result can be used by plot.igraph as well.

Usage

network.layout.extract_coordinates(n, layout.par)

Arguments

n

A network or igraph object. Not used, only for compatibility with plot.network.

layout.par

A list of layout parameters (the only one implemented is layout.par$sf, an sf object whose rows match the order of vertices in n).

Value

A matrix whose rows contain the x,y coordinates of the vertices of n.

Examples

net=network::network(matrix(c(0, 1, 1, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0), nrow=4, byrow=TRUE))
network::set.vertex.attribute(net, "name", value=c("a", "b", "c", "d"))
wkb = structure(list("01010000204071000000000000801A064100000000AC5C1641",
"01010000204071000000000000801A084100000000AC5C1441",
"01010000204071000000000000801A044100000000AC5C1241",
"01010000204071000000000000801A024100000000AC5C1841"), class = "WKB")
map=sf::st_sf(id=c("a1", "b2", "c3", "d4"), sf::st_as_sfc(wkb, EWKB=TRUE))
lkptbl=data.frame(id=c("a1", "b2", "c3", "d4"), name=c("a", "b", "c", "d"))
netmap::network.layout.extract_coordinates(net, list(sf=map))

[Package netmap version 0.1.4 Index]