This expects graph to have a lat and lon vertex attribute, however you may pass in alternate numeric vectors to v_lat and v_lon.

graph_to_sf(graph, v_lat = igraph::vertex_attr(graph, "lat"),
  v_lon = igraph::vertex_attr(graph, "lon"))

edges_to_sf(graph, v_lat = igraph::vertex_attr(graph, "lat"),
  v_lon = igraph::vertex_attr(graph, "lon"))

nodes_to_sf(graph, v_lat = igraph::vertex_attr(graph, "lat"),
  v_lon = igraph::vertex_attr(graph, "lon"))

Arguments

graph

An igraph object

v_lat

Numeric. Latitude values for each vertex

v_lon

Numeric. Longitude values for each vertex

Value

A named list with an edges and a nodes sfc object.

Functions

  • edges_to_sf: Return only the edges as an st_linestring object

  • nodes_to_sf: Return only the nodes as an st_point object