This function is to split nodes and edges from a “SpatialLines” or “SpatialLinesDataFrame” object, and return “nodelist” and “edgelist”.
readshpnw(data=list(), ELComputed=FALSE, longlat=FALSE, Detailed=FALSE, ea.prop=NULL)
A “SpatialLines” or “SpatialLinesDataFrame” object;
if TRUE, the edge length will be computed
If TRUE, distance will be calculated on an ellipse with WGS84 parameters;
Default is FALSE, only two endpoints (starting and ending) of each polyline are recognised as nodes and collected in the “nodelist”; If TRUE, all the endpoints will be recognised as nodes and collected.
If data is a “SpatialLinesDataFrame” object and “Detailed” is TRUE, the ea.prop shoul be a given as a vector (of lenght equal to the number of columns in data.frame(data)) with values 0 or 1, for defining the rules of re-attributing the new edges: 0 means that equalization is used for the arrtibute inherition from the original data; 1 implies that weighted-mean based on the edge length is adopted.
A list consisted of:
TRUE if the output is under a “Detailed” mode, and “edgelist” will have a different structure;
A “nodelist” object
An “edgelist” object
A vector (of length equal to the number of edges) of edge lengths if “ELComputed” is TRUE;
A data frame of edge attributes, [EdgeID,...(items extracted from the “SpatialLinesDataFrame” object )...]
A vector contains X-coordinates of all the nodes
A vector contains Y-coordinates of all the nodes
This function is the first step to convert a newtwork data into an object of “igraph”. With a given “SpatialLines” or “SpatialLinesDataFrame”, it produces a nodelist, “edgelist”, and data frame for edge attributes.
# NOT RUN {
data(ORN)
rtNEL<-readshpnw(rn)
nl<-rtNEL[[2]]
el<-rtNEL[[3]]
#Compute edge length
rtNEL<-readshpnw(rn, ELComputed=TRUE)
edgelength<-rtNEL[[4]]
eadf<-rtNEL[[5]]
# }
Run the code above in your browser using DataLab