netmap_plot: Plot a network object with a layout based on an 'sf' object

View source: R/netmap_plot.R

netmap_plotR Documentation

Plot a network object with a layout based on an sf object

Description

Wrapper for plot.network and plot.igraph using a custom network layout that extracts coordinates of centroids from a sf object. Only vertices with a corresponding feature are plotted.

Usage

netmap_plot(n, m, lkp = NULL, m_name = NULL, n_name = "vertex.names", ...)

Arguments

n

A network or igraph object.

m

A sf object.

lkp

An optional lookup table.

m_name

Optional character, name of field in m and of column in lkp.

n_name

Optional character, name of vertex attribute in n and of column in lkp.

...

Additional parameters passed to plot.network.

Value

A plot of the network.

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::netmap_plot(net, map, lkptbl, "id", "name")

netmap documentation built on May 29, 2024, 11:10 a.m.