ggconn_area {netmap}R Documentation

Calculate connectedness to a specific vertex for vertices linked to a sf object

Description

Given a sf object with features that can be linked to a network or igraph object and given a node with id id in said graph that can be linked to the sf object, obtain an indicator variable denoting, for each node, a connection to id.

Usage

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

Arguments

n

A network or igraph object.

m

A sf object.

id

The identifier (as vertex attribute n_name of object n) of the feature that needs to be checked for connections.

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.

Value

An sf object, input m with an added column conn_area with an indicator variable set to 1 if the feature is connected to the feature with vertex id id, 0 otherwise. In directed graphs, only outgoing links are considered a connection. Any existing column with the same name will be overwritten, the result will contain only the features linked to vertices in input. If the vertex id is not present in object n, conn_area will be set to 0 for all vertices.

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

[Package netmap version 0.1.4 Index]