Create an igraph object with geospatial attributes for the nodes.

geonetwork(edges, nodes, directed = TRUE,
  CRS = sp::CRS("+proj=longlat"))



data.frame. Edges list and attributes. See Details.


data.frame. Nodes list and attributes. See Details.


logical. Default is to build a directed graph.


CRS object. Coordinate Reference System, as built by function CRS.


An object of class geonetwork, which also inherits from igraph.


The first two columns in edges must be character or factor, and match the node names in the first column of the nodes data.frame. The third column, if any, will be used as edge weights. The remaining columns will be used as additional edge attributes.

The first column in nodes must be character or factor and provide node names or labels, not necessarily unique. Columns 2 and 3 must be numeric coordinates in the Coordinate Reference System specified in CRS.


e <- data.frame(from = c("A", "A"), to = c("B", "C")) n <- data.frame(id = LETTERS[1:3], x = c(0, 0, 1), y = c(0, 1, 0)) geonetwork(e, n)
#> IGRAPH 473a4a5 DN-- 3 2 -- #> + attr: name (v/c) #> + edges from 473a4a5 (vertex names): #> [1] A->B A->C