Hello I have a network in R using the igraph library
Vertices: 616
Edges: 6270
Directed: TRUE
No graph attributes.
Vertex attributes: name, Lat, Lon.
Edge attributes: V3.
How can I generate two shapefiles for the Vertices and the Edges using the Lat, Lon info in the vertex?
You can do this using the
spandmaptoolspackages. There are handy functionswritePointsShape()andwriteLinesShape()inmaptoolsthat will write to the ESRI shapefile format.Before doing this, it is necessary to extract the lat/lon information from the graph vertices and put it into a
SpatialPointsobject for the vertices, and aSpatialLinesDataFrameobject for the edges.This code produces a very simple
igraphobject for the following example:Now, create the
SpatialPointsobject for the verticesFinally, create the
SpatialLinesDataFrameobject for the edges. This is a little messy, but I am yet to find a quick way to produce a SpatialLines object given coordinates.