Description
This tool creates a spatial graph based on discontinuous (non-touching) polygons. (To create a graph based on polygon adjacency see the calc.sharedborders command.) To create the nodes a single point is generated to represent each polygon using either the centroid or label point methods (see the genpointinpoly command for a description of these terms). Nodes are connected if the shortest distance between the polygons they represent is no larger than the distance threshold specified. The command generates two types of edge outputs: the straight lines connecting the node points, and the lines (links) representing the shortest distance between polygons. The length of both edges and links is written to both attribute tables, and the edge export file.
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.createfrompolygons(in, uidfield, distance, outline, outpoint, outlink, exportnode, exportedge, [nodeweightfield], [centroid], [where]);
| in | the input polygon 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 | |
| outpoint | the output point (node) feature data source | |
| outlink | the output link (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) | |
| [centroid] | (TRUE/FALSE) if TRUE uses the centroid point of the polygon for the node, if FALSE uses the label point) | |
| [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.createfrompolygons(in="C:\data\points.shp", uidfield="PNTID", outline="C:\data\graphedges.shp", outlink="C:\data\graphlinks.shp", exportnode="C:\data\exportnodes.csv", exportedge="C:\data\exportedges.shp");
graph.createfrompolygons(in="C:\data\patchpolygons.shp", uidfield="PATCHID", outline="C:\data\graphedges.shp", outlink="C:\data\graphlinks.shp", exportnode="C:\data\exportnodes.csv", exportedge="C:\data\exportedges.shp", nodeweightfield="AREA", where="POPULATION > 0");