Description
This tool converts a point dataset representing graph nodes to a spatial graph by connecting nodes automatically using a distance threshold. The edges are output as a line feature dataset, and the nodes and edges are export as two delimited text files that can be easily read into R. The unique point ID field is preserved in the exported node data so that the connection with the original point data can be preserved. An optional node wieght field can also be specified, which results in an extra column of data being written to the export file.
The graph can be created in R using the igraph library as follows.
setwd("C:\\gme\\mygraphdata")
require(igraph)
edata <- read.csv("exportedges.csv")
ndata <- read.csv("exportnodes.csv")
graph1 <- graph.data.frame(edata[,-1], directed=FALSE, vertices=NULL)
Syntax
graph.createfrompoints(in, uidfield, distance, outline, exportnode, exportedge, [nodeweightfield], [where]);
| in | the input point data source that represents graph nodes | |
| uidfield | the unique feature ID field for the input data source | |
| distance | the threshold distance for connecting nodes | |
| outline | the output line feature data source | |
| exportnode | the graph node export csv file | |
| exportedge | the graph edge export csv file | |
| [nodeweightfield] | a field name containing node weights to be included in the export file) | |
| [where] | the selection statement that will be applied to the input feature data source to identify a subset of features to process (see full Help documentation for further details) |
Example
graph.createfrompoints(in="C:\data\points.shp", uidfield="PNTID", outline="C:\data\graphedges.shp", exportnode="C:\data\exportnodes.csv", exportedge="C:\data\exportedges.shp");
graph.createfrompoints(in="C:\data\patchpolygons.shp", uidfield="PATCHID", outline="C:\data\graphedges.shp", exportnode="C:\data\exportnodes.csv", exportedge="C:\data\exportedges.shp", nodeweightfield="POPULATION", where="POPULATION > 0");